Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IBGBUGCHAT-10593] support certificate content type #6

Open
wants to merge 1 commit into
base: url-filter
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 StandardError
end
end
end