From a919792f5aa5eb800647284ebbf0495236c40af5 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Fri, 29 Apr 2016 14:37:57 +0200 Subject: [PATCH] Fix for extension and filename storage Previously it was saved without quotes, which resulted in incorrect filename display in Firefox. Also, file extension was deduced from the file_format, while now we deduce it from the original filename (if not already specified in the asset name). --- pillar/application/utils/gcs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pillar/application/utils/gcs.py b/pillar/application/utils/gcs.py index 551d768f..f0f4b137 100644 --- a/pillar/application/utils/gcs.py +++ b/pillar/application/utils/gcs.py @@ -135,7 +135,7 @@ class GoogleCloudStorageBucket(object): """Set the ContentDisposition metadata so that when a file is downloaded it has a human-readable name. """ - blob.content_disposition = "attachment; filename={0}".format(name) + blob.content_disposition = 'attachment; filename="{0}"'.format(name) blob.patch() @@ -161,7 +161,9 @@ def update_file_name(item): try: storage = GoogleCloudStorageBucket(str(item['project'])) blob = storage.Get(f['file_path'], to_dict=False) - name = _format_name(item['name'], f['format']) + # Pick file extension from original filename + _, ext = os.path.splitext(f['filename']) + name = _format_name(item['name'], ext[1:]) storage.update_name(blob, name) try: # Assign the same name to variations