This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git


The following commit(s) were added to refs/heads/master by this push:
     new d0de482  AIRAVATA-3697 Set filename appropriately when downloading 
file with utf8 characters
d0de482 is described below

commit d0de482e134b2aac883d8c67da3a7481613ed97d
Author: Marcus Christie <[email protected]>
AuthorDate: Fri Apr 28 16:28:32 2023 -0400

    AIRAVATA-3697 Set filename appropriately when downloading file with utf8 
characters
---
 airavata_django_portal_sdk/views.py | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/airavata_django_portal_sdk/views.py 
b/airavata_django_portal_sdk/views.py
index 31c3a41..39a9602 100644
--- a/airavata_django_portal_sdk/views.py
+++ b/airavata_django_portal_sdk/views.py
@@ -54,17 +54,12 @@ def download_file(request):
         raise Http404("data product does not exist") from e
     try:
         data_file = user_storage.open_file(request, data_product)
-        response = FileResponse(data_file, content_type=mime_type)
+        as_attachment = (mime_type == 'application/octet-stream' or 
force_download)
         if user_storage.is_input_file(request, data_product):
             file_name = data_product.productName
         else:
             file_name = os.path.basename(data_file.name)
-        if mime_type == 'application/octet-stream' or force_download:
-            response['Content-Disposition'] = ('attachment; filename="{}"'
-                                               .format(file_name))
-        else:
-            response['Content-Disposition'] = f'inline; filename="{file_name}"'
-        return response
+        return FileResponse(data_file, content_type=mime_type, 
as_attachment=as_attachment, filename=file_name)
     except ObjectDoesNotExist as e:
         raise Http404(str(e)) from e
 

Reply via email to