diff --git a/lib/carrierwave/sanitized_file.rb b/lib/carrierwave/sanitized_file.rb index 21133c49a..054957065 100644 --- a/lib/carrierwave/sanitized_file.rb +++ b/lib/carrierwave/sanitized_file.rb @@ -315,7 +315,11 @@ def existing_content_type end def mime_magic_content_type - MimeMagic.by_magic(File.open(path)).try(:type) if path + if path + File.open(path) do |file| + MimeMagic.by_magic(file).try(:type) + end + end rescue Errno::ENOENT nil end