diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-21 21:02:38 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-21 21:02:38 +0000 |
commit | 64763bece35c76f611ceaedd243aa93cb1358344 (patch) | |
tree | 680cca7eb4878806e908442be906ec7517461f59 /app | |
parent | b8a586c4750f963e0681903d2d03f309ddb8d497 (diff) | |
download | redmine-64763bece35c76f611ceaedd243aa93cb1358344.tar.gz redmine-64763bece35c76f611ceaedd243aa93cb1358344.zip |
Attachment content type not set when uploading attachment (#18667).
git-svn-id: http://svn.redmine.org/redmine/trunk@13787 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/attachment.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 42690912a..a008c4a29 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -52,7 +52,7 @@ class Attachment < ActiveRecord::Base cattr_accessor :thumbnails_storage_path @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") - before_save :files_to_final_location + before_create :files_to_final_location after_destroy :delete_from_disk # Returns an unsaved copy of the attachment @@ -80,9 +80,6 @@ class Attachment < ActiveRecord::Base if @temp_file.respond_to?(:content_type) self.content_type = @temp_file.content_type.to_s.chomp end - if content_type.blank? && filename.present? - self.content_type = Redmine::MimeType.of(filename) - end self.filesize = @temp_file.size end end @@ -124,6 +121,10 @@ class Attachment < ActiveRecord::Base self.digest = md5.hexdigest end @temp_file = nil + + if content_type.blank? && filename.present? + self.content_type = Redmine::MimeType.of(filename) + end # Don't save the content type if it's longer than the authorized length if self.content_type && self.content_type.length > 255 self.content_type = nil |