diff --git a/lib/paperclip/content_type_detector.rb b/lib/paperclip/content_type_detector.rb index e0d587458..a1f822bb5 100644 --- a/lib/paperclip/content_type_detector.rb +++ b/lib/paperclip/content_type_detector.rb @@ -60,7 +60,7 @@ def calculated_type_matches end def type_from_file_contents - certificate_type || type_from_file_command + (certificate_type || pkcs8_type || type_from_file_command) rescue Errno::ENOENT => e Paperclip.log("Error while determining content type: #{e}") SENSIBLE_DEFAULT @@ -76,5 +76,11 @@ def certificate_type 'application/x-x509-ca-cert' rescue StandardError end + + def pkcs8_type + key = OpenSSL::PKey.read(File.read(@filename)) + 'application/pkcs8' + rescue StandardError + end end end