From 5f8e8877f1f11328beb6984adf64a96c96dd0e7d Mon Sep 17 00:00:00 2001 From: Mark Calvert Date: Fri, 1 Nov 2024 02:13:47 +0000 Subject: [PATCH] Synced from resource view override. https://github.com/ckan/ckan/pull/6888/files --- ckanext/fortify/blueprint.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ckanext/fortify/blueprint.py b/ckanext/fortify/blueprint.py index 916d6d0..102fdc8 100644 --- a/ckanext/fortify/blueprint.py +++ b/ckanext/fortify/blueprint.py @@ -4,6 +4,7 @@ import ckan.lib.mailer as mailer import ckan.lib.navl.dictization_functions as dictization_functions import ckan.lib.uploader as uploader +from ckan.lib import signals import flask from ckan.views.user import PerformResetView @@ -156,7 +157,11 @@ def download(package_type, id, resource_id, filename=None): # This will set the header headers.add('Content-Disposition', 'attachment', filename=attachment_filename) return flask.send_file(filepath, mimetype=upload.mimetype, as_attachment=True, attachment_filename=filename) else: - return flask.send_file(filepath) + resp = flask.send_file(filepath, download_name=filename) + if rsc.get('mimetype'): + resp.headers['Content-Type'] = rsc['mimetype'] + signals.resource_download.send(resource_id) + return resp # Fortify updates end elif u'url' not in rsc: return abort(404, _(u'No download is available'))