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 2020/09/17 13:43:51 UTC

[airavata-django-portal-sdk] 01/05: AIRAVATA-3346: AIRAVATA-3346 Fixing preservation of content type in uploads

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

machristie pushed a commit to branch AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git

commit d3bf173e033a14aa48c2208808dd6ac924ee0ed1
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Sep 16 10:49:14 2020 -0400

    AIRAVATA-3346: AIRAVATA-3346 Fixing preservation of content type in uploads
---
 airavata_django_portal_sdk/user_storage.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/airavata_django_portal_sdk/user_storage.py b/airavata_django_portal_sdk/user_storage.py
index fcc761f..2570e86 100644
--- a/airavata_django_portal_sdk/user_storage.py
+++ b/airavata_django_portal_sdk/user_storage.py
@@ -33,9 +33,10 @@ def save(request, path, file, name=None, content_type=None):
     if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
         headers = {
             'Authorization': f'Bearer {request.authz_token.accessToken}'}
+        if name is None and hasattr(file, 'name'):
+            name = os.path.basename(file.name)
         files = {
-            # 'file': (name, file, content_type)
-            'file': file
+            'file': (name, file, content_type) if content_type is not None else file,
         }
         r = requests.post(
             f'{settings.GATEWAY_DATA_STORE_REMOTE_API}/user-storage/~/{path}',