Method: FileColumn::TempUploadedFile#get_content_type

Defined in:
lib/file_column.rb

#get_content_type(fallback = nil) ⇒ Object



323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/file_column.rb', line 323

def get_content_type(fallback=nil)
  if options[:file_exec]
    begin
      content_type = `#{options[:file_exec]} -bi "#{File.join(@dir,@filename)}"`.chomp
      content_type = fallback unless $?.success?
      content_type.gsub!(/;.+$/,"") if content_type
      content_type
    rescue
      fallback
    end
  else
    fallback
  end
end