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.git
The following commit(s) were added to refs/heads/master by this push:
new 3f62901 Use file name for name of downloaded file
3f62901 is described below
commit 3f62901b7668763beca48bbf31009506cebc0875
Author: Marcus Christie <[email protected]>
AuthorDate: Mon Mar 11 17:01:23 2019 -0400
Use file name for name of downloaded file
---
django_airavata/apps/api/views.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/django_airavata/apps/api/views.py
b/django_airavata/apps/api/views.py
index a6b3128..4e01de9 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1,4 +1,5 @@
import logging
+import os
from django.conf import settings
from django.contrib.auth.decorators import login_required
@@ -747,8 +748,9 @@ def download_file(request):
data_file = datastore.open(data_product)
response = FileResponse(data_file,
content_type="application/octet-stream")
+ file_name = os.path.basename(data_file.name)
response['Content-Disposition'] = ('attachment; filename="{}"'
- .format(data_product.productName))
+ .format(file_name))
return response
except ObjectDoesNotExist as e:
raise Http404(str(e)) from e