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).
This commit is contained in:
Francesco Siddi 2016-04-29 14:37:57 +02:00
parent 6673e31675
commit a919792f5a

View File

@ -135,7 +135,7 @@ class GoogleCloudStorageBucket(object):
"""Set the ContentDisposition metadata so that when a file is downloaded """Set the ContentDisposition metadata so that when a file is downloaded
it has a human-readable name. it has a human-readable name.
""" """
blob.content_disposition = "attachment; filename={0}".format(name) blob.content_disposition = 'attachment; filename="{0}"'.format(name)
blob.patch() blob.patch()
@ -161,7 +161,9 @@ def update_file_name(item):
try: try:
storage = GoogleCloudStorageBucket(str(item['project'])) storage = GoogleCloudStorageBucket(str(item['project']))
blob = storage.Get(f['file_path'], to_dict=False) 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) storage.update_name(blob, name)
try: try:
# Assign the same name to variations # Assign the same name to variations