diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f57038b9..4591a110 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -61,6 +61,10 @@ class Attachment < ActiveRecord::Base end self.digest = Digest::MD5.hexdigest(File.read(diskfile)) 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 + end end # Deletes file on the disk diff --git a/db/migrate/070_change_attachments_content_type_limit.rb b/db/migrate/070_change_attachments_content_type_limit.rb new file mode 100644 index 00000000..e3dfacc3 --- /dev/null +++ b/db/migrate/070_change_attachments_content_type_limit.rb @@ -0,0 +1,9 @@ +class ChangeAttachmentsContentTypeLimit < ActiveRecord::Migration + def self.up + change_column :attachments, :content_type, :string + end + + def self.down + change_column :attachments, :content_type, :string, :limit => 60 + end +end