diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-29 13:28:30 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-12-29 13:28:30 +0000 |
commit | ff7eb7b23a6aa86f4bc1a2d73ee0a3a4f1487ba7 (patch) | |
tree | ab6b2c2a4c24576a32bf193dad9cd934e4150a35 /app/controllers/attachments_controller.rb | |
parent | b7b4e27833b08b07131d724aa4b1a411f2a13aa0 (diff) | |
download | redmine-ff7eb7b23a6aa86f4bc1a2d73ee0a3a4f1487ba7.tar.gz redmine-ff7eb7b23a6aa86f4bc1a2d73ee0a3a4f1487ba7.zip |
Auto-detect attachment content type when blank (#3782).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3258 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/attachments_controller.rb')
-rw-r--r-- | app/controllers/attachments_controller.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 92d60ee0f..92fa01e8f 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -41,7 +41,7 @@ class AttachmentsController < ApplicationController # images are sent inline send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => @attachment.content_type, + :type => detect_content_type(@attachment), :disposition => (@attachment.image? ? 'inline' : 'attachment') end @@ -76,4 +76,12 @@ private def delete_authorize @attachment.deletable? ? true : deny_access end + + def detect_content_type(attachment) + content_type = attachment.content_type + if content_type.blank? + content_type = Redmine::MimeType.of(attachment.filename) + end + content_type + end end |