Browse files

Don't use --mime-type

The `file` command on OS X takes the --mime-type option, which returns
only the type and not the optional encoding. This is nice, but it's not
portable. Use --mime and strip the encoding off if it's there.

And don't forget this time.
  • Loading branch information...
1 parent ae89f79 commit ea922128316918dc7931973fdefbfe4da33a28a1 @jyurek jyurek committed Feb 26, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/paperclip/media_type_spoof_detector.rb
@@ -52,7 +52,7 @@ def filename_extension
def type_from_file_command
-"file", "-b --mime-type :file", :file => @file.path)
+"file", "-b --mime :file", :file => @file.path).split(/[:;]\s+/).first
rescue Cocaine::CommandLineError

1 comment on commit ea92212


janko-m commented on ea92212 May 6, 2016

May I ask, why is this not portable? Do some other OSes not support the --mime-type option? Do you know an example of one?

Please sign in to comment.