From 40328f055ed1434e7cbf2084d1c7d3a7907ea95f Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 16 May 2019 09:47:22 +0530 Subject: [PATCH] FIX: retrieve original filename from s3 object's content disposition header --- lib/s3_inventory.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb index 35e81394796..69d78d88536 100644 --- a/lib/s3_inventory.rb +++ b/lib/s3_inventory.rb @@ -85,10 +85,11 @@ class S3Inventory if result.count >= 1 key = result[0]["key"] data = @s3_helper.object(key).data + filename = (data.content_disposition&.match(/filename=\"(.*)\"/) || [])[1] upload_id = Upload.create!( user_id: Discourse.system_user.id, - original_filename: "", + original_filename: filename || File.basename(key), filesize: data.content_length, url: File.join(Discourse.store.absolute_base_url, key), sha1: sha1,