Module: WebpackerUploader::Mime
- Defined in:
- lib/webpacker_uploader/mime.rb
Class Method Summary collapse
-
.mime_type(file_path) ⇒ String
Returns the mime type for the given file in the filesystem.
Class Method Details
.mime_type(file_path) ⇒ String
Returns the mime type for the given file in the filesystem. If it's unable to detect the mime type, it returns +application/octet-stream+ as a fallback.
12 13 14 15 |
# File 'lib/webpacker_uploader/mime.rb', line 12 def mime_type(file_path) fallback = MIME::Types.type_for(file_path).first&.content_type || "application/octet-stream" Rack::Mime.mime_type(File.extname(file_path), fallback) end |