FIX: retrieve original filename from s3 object's content disposition header

This commit is contained in:
Vinoth Kannan 2019-05-16 09:47:22 +05:30
parent 227bedebf7
commit 40328f055e
1 changed files with 2 additions and 1 deletions

View File

@ -85,10 +85,11 @@ class S3Inventory
if result.count >= 1 if result.count >= 1
key = result[0]["key"] key = result[0]["key"]
data = @s3_helper.object(key).data data = @s3_helper.object(key).data
filename = (data.content_disposition&.match(/filename=\"(.*)\"/) || [])[1]
upload_id = Upload.create!( upload_id = Upload.create!(
user_id: Discourse.system_user.id, user_id: Discourse.system_user.id,
original_filename: "", original_filename: filename || File.basename(key),
filesize: data.content_length, filesize: data.content_length,
url: File.join(Discourse.store.absolute_base_url, key), url: File.join(Discourse.store.absolute_base_url, key),
sha1: sha1, sha1: sha1,