Added a try block to wrap the existing code in the resource_read method within the CustomPackageController class.
try:
r = requests.head(c.resource['url'])
if r.status_code not in (400, 403, 405) and r.ok:
size = r.headers.get('content-length')
if size and int(size) > MAX_FILE_SIZE:
h.flash_error('Sorry, this file is too large to be able to display in the browser, please download the data resource to examine it further.')
except Exception as e:
print(e)
h.flash_error('Unable to get resource')
Fixes: https://gitlab.com/datopian/core/support/-/issues/306
Files updated
ckanext/opendatani/ontroller.py
resource_read
method within theCustomPackageController
class.