Sha256: 91148071acf2c1807135c98478c4f16f5ccd243597456c850706d571135e72ee
Contents?: true
Size: 815 Bytes
Versions: 17
Compression:
Stored size: 815 Bytes
Contents
module Dragonfly module Analysis class FileCommandAnalyser include Configurable configurable_attr :file_command, "file" configurable_attr :use_filesystem, false configurable_attr :num_bytes_to_check, 255 def mime_type(temp_object) content_type = if use_filesystem `#{file_command} -b --mime '#{temp_object.path}'` else IO.popen("#{file_command} -b --mime -", 'r+') do |io| if num_bytes_to_check io.write temp_object.data[0, num_bytes_to_check] else io.write temp_object.data end io.close_write io.read end end.split(';').first content_type.strip if content_type end end end end
Version data entries
17 entries across 17 versions & 3 rubygems