Skip to content

Commit

Permalink
support certificate content type
Browse files Browse the repository at this point in the history
  • Loading branch information
smohamedinstabug committed Dec 6, 2020
1 parent 4186e38 commit 9361442
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/paperclip/content_type_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def calculated_type_matches
end

def type_from_file_contents
type_from_mime_magic || type_from_file_command
type_from_mime_magic || certificate_type || type_from_file_command
rescue Errno::ENOENT => e
Paperclip.log("Error while determining content type: #{e}")
SENSIBLE_DEFAULT
Expand All @@ -75,5 +75,11 @@ def type_from_mime_magic
@type_from_mime_magic ||=
MimeMagic.by_magic(File.open(@filename)).try(:type)
end

def certificate_type
OpenSSL::X509::Certificate.new(File.read(@filename))
'application/x-x509-ca-cert'
rescue Exception
end
end
end

0 comments on commit 9361442

Please sign in to comment.