From 80468037e91a83c232267902f03ab8e3b00e2167 Mon Sep 17 00:00:00 2001 From: Mesut Kayman Date: Tue, 9 Sep 2014 19:43:02 +0300 Subject: [PATCH] Don't set content-disposition header for images If this header is set for images, clicking the image link causes them to automatically download the file, rather than viewing it inside the browser. This commit forces this behavior only for uploads that aren't images --- lib/file_store/s3_store.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb index 7d2dcd3bd..c75bdbfca 100644 --- a/lib/file_store/s3_store.rb +++ b/lib/file_store/s3_store.rb @@ -139,7 +139,11 @@ module FileStore public: true, body: file } - args[:content_disposition] = "attachment; filename=\"#{filename}\"" if filename + + if filename && !FileHelper.is_image?(filename) + args[:content_disposition] = "attachment; filename=\"#{filename}\"" + end + args[:content_type] = content_type if content_type get_or_create_directory(s3_bucket).files.create(args)