Commit a7f01bec by Jon Yurek

Changed auto-content-typing in Upfile to be a little more intelligent.

parent 201c84ba
......@@ -6,12 +6,13 @@ module Paperclip
# Infer the MIME-type of the file from the extension.
def content_type
type = self.path.match(/\.(\w+)$/)[1] rescue "octet-stream"
type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
case type
when "jpg" then "image/jpeg"
when "png", "gif" then "image/#{type}"
when "txt" then "text/plain"
when "csv", "xml", "html", "htm", "css", "js" then "text/#{type}"
when %r"jpe?g" then "image/jpeg"
when %r"png", "gif", "bmp", "tiff" then "image/#{type}"
when "txt" then "text/plain"
when %r"html?" then "text/html"
when "csv", "xml", "css", "js" then "text/#{type}"
else "application/x-#{type}"
end
end
......@@ -32,3 +33,4 @@ end
class File #:nodoc:
include Paperclip::Upfile
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment