You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/07/06 14:57:05 UTC
[airavata-django-portal-sdk] branch master updated: AIRAVATA-3420
Preserve mime-type query param
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 3b0a4ee AIRAVATA-3420 Preserve mime-type query param
3b0a4ee is described below
commit 3b0a4ee7e3e32d0a33793c3ad32fde61864018ae
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Jul 6 10:56:47 2021 -0400
AIRAVATA-3420 Preserve mime-type query param
---
airavata_django_portal_sdk/user_storage/api.py | 4 +++-
airavata_django_portal_sdk/views.py | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/airavata_django_portal_sdk/user_storage/api.py b/airavata_django_portal_sdk/user_storage/api.py
index fbdd0a7..b015af7 100644
--- a/airavata_django_portal_sdk/user_storage/api.py
+++ b/airavata_django_portal_sdk/user_storage/api.py
@@ -186,7 +186,7 @@ def move_input_file(request, data_product=None, path=None, data_product_uri=None
return move(request, data_product=data_product, path=path, data_product_uri=data_product_uri, storage_resource_id=storage_resource_id)
-def get_download_url(request, data_product=None, data_product_uri=None, force_download=False):
+def get_download_url(request, data_product=None, data_product_uri=None, force_download=False, mime_type=None):
"Return URL for downloading data product. One of `data_product` or `data_product_uri` is required."
if data_product is None:
data_product = _get_data_product(request, data_product_uri)
@@ -202,6 +202,8 @@ def get_download_url(request, data_product=None, data_product_uri=None, force_do
params = {"data-product-uri": data_product.productUri}
if force_download:
params['download'] = ''
+ if mime_type is not None:
+ params['mime-type'] = mime_type
return f"{reverse('airavata_django_portal_sdk:download_file')}?{urlencode(params)}"
diff --git a/airavata_django_portal_sdk/views.py b/airavata_django_portal_sdk/views.py
index 8cae056..498402f 100644
--- a/airavata_django_portal_sdk/views.py
+++ b/airavata_django_portal_sdk/views.py
@@ -21,9 +21,11 @@ MAX_DOWNLOAD_ZIPFILE_SIZE = 1 * 1024**3 # 1 GB
def download(request):
data_product_uri = request.GET.get('data-product-uri', '')
force_download = 'download' in request.GET
+ mime_type = request.GET.get('mime-type')
download_url = user_storage.get_download_url(request,
data_product_uri=data_product_uri,
- force_download=force_download)
+ force_download=force_download,
+ mime_type=mime_type)
return redirect(download_url)