Skip to content

Instantly share code, notes, and snippets.

@sax
Created August 10, 2017 18:01
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 sax/1b400d164f1a2f6d26b57e85465072bf to your computer and use it in GitHub Desktop.
Save sax/1b400d164f1a2f6d26b57e85465072bf to your computer and use it in GitHub Desktop.
paperclip content-type detection for Office
module Paperclip
module ContentTypeDetectorOverrides
def calculated_type_matches
possible_types.select do |content_type|
if content_type.start_with?('application/vnd.openxmlformats-officedocument')
content_type == type_from_file_contents ||
type_from_file_contents == 'application/zip'
else
content_type == type_from_file_contents
end
end
end
end
class ContentTypeDetector
prepend ContentTypeDetectorOverrides
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment