Module: Paperclip::Commands::UnixFile

Extended by:
UnixFile
Included in:
UnixFile
Defined in:
lib/paperclip/commands/unix_file.rb

Instance Method Summary collapse

Instance Method Details

#detect_content_type(file) ⇒ Object

Returns a normalized content type value, otherwise nil.



9
10
11
12
13
14
15
16
17
# File 'lib/paperclip/commands/unix_file.rb', line 9

def detect_content_type(file)
  type = run_file_command(file)
  return if type.blank? || type.match(/\(.*?\)/)

  type.split(/[:;\s]+/)[0].strip
rescue Terrapin::CommandLineError => e
  Paperclip.log("Error while determining content type: #{e}")
  nil
end