Skip to content

Instantly share code, notes, and snippets.

@samstokes
Created May 27, 2009 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samstokes/118590 to your computer and use it in GitHub Desktop.
Save samstokes/118590 to your computer and use it in GitHub Desktop.
# 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