Created
May 27, 2009 11:22
-
-
Save samstokes/118590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Override Paperclip's content-type guessing support to add more MIME types. | |
# We actually have to monkey-patch File to do this, because Paperclip | |
# monkey-patches File to add #content_type (from module Paperclip::Upfile). | |
class File | |
def content_type_with_extras | |
type = (self.path.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase | |
case type | |
when "pdf" then "application/pdf" | |
# add more content types here | |
else content_type_without_extras | |
end | |
end | |
alias_method_chain :content_type, :extras | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment