Created
August 10, 2017 18:01
-
-
Save sax/1b400d164f1a2f6d26b57e85465072bf to your computer and use it in GitHub Desktop.
paperclip content-type detection for Office
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
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