lib/carrierwave/sanitized_file.rb in carrierwave-2.2.0 vs lib/carrierwave/sanitized_file.rb in carrierwave-2.2.1

- old
+ new

@@ -1,10 +1,9 @@ require 'pathname' require 'active_support/core_ext/string/multibyte' require 'mini_mime' -require 'mimemagic' -require 'mimemagic/overlay' +require 'marcel' module CarrierWave ## # SanitizedFile is a base class which provides a common API around all @@ -260,11 +259,11 @@ # [String] the content type of the file # def content_type @content_type ||= existing_content_type || - mime_magic_content_type || + marcel_magic_content_type || mini_mime_content_type end ## # Sets the content type of the file. @@ -327,17 +326,17 @@ if @file.respond_to?(:content_type) && @file.content_type @file.content_type.to_s.chomp end end - def mime_magic_content_type + def marcel_magic_content_type if path type = File.open(path) do |file| - MimeMagic.by_magic(file).try(:type) + Marcel::Magic.by_magic(file).try(:type) end if type.nil? - type = ::MiniMime.lookup_by_filename(path).try(:content_type) + type = Marcel::Magic.by_path(file).try(:type) type = 'invalid/invalid' unless type.nil? || type.start_with?('text/') end type end