FIX: pull hotlinked images even when they have no extension

This commit is contained in:
Régis Hanol
2017-06-13 13:27:05 +02:00
parent a5d3abc9b6
commit 5d63a7f4a6
7 changed files with 43 additions and 14 deletions

View File

@ -1,4 +1,5 @@
require "uri"
require "mini_mime"
require_dependency "file_store/base_store"
require_dependency "s3_helper"
require_dependency "file_helper"
@ -33,7 +34,7 @@ module FileStore
# stored uploaded are public by default
options = {
acl: "public-read",
content_type: opts[:content_type].presence || Rack::Mime.mime_type(File.extname(filename))
content_type: opts[:content_type].presence || MiniMime.lookup_by_filename(filename)&.content_type
}
# add a "content disposition" header for "attachments"
options[:content_disposition] = "attachment; filename=\"#{filename}\"" unless FileHelper.is_image?(filename)