File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
s . add_dependency "activemodel" , ">= 5.0.0"
26
26
s . add_dependency "mini_mime" , ">= 0.1.3"
27
27
s . add_dependency "image_processing" , "~> 1.1"
28
- s . add_dependency "mimemagic " , ">= 0.3 .0"
28
+ s . add_dependency "marcel " , "~> 1.0 .0"
29
29
s . add_dependency "addressable" , "~> 2.6"
30
30
s . add_dependency "ssrf_filter" , "~> 1.0"
31
31
if RUBY_ENGINE == 'jruby'
Original file line number Diff line number Diff line change 1
1
require 'pathname'
2
2
require 'active_support/core_ext/string/multibyte'
3
3
require 'mini_mime'
4
- require 'mimemagic'
5
- require 'mimemagic/overlay'
4
+ require 'marcel'
6
5
7
6
module CarrierWave
8
7
@@ -262,7 +261,7 @@ def to_file
262
261
def content_type
263
262
@content_type ||=
264
263
existing_content_type ||
265
- mime_magic_content_type ||
264
+ marcel_magic_content_type ||
266
265
mini_mime_content_type
267
266
end
268
267
@@ -329,14 +328,14 @@ def existing_content_type
329
328
end
330
329
end
331
330
332
- def mime_magic_content_type
331
+ def marcel_magic_content_type
333
332
if path
334
333
type = File . open ( path ) do |file |
335
- MimeMagic . by_magic ( file ) . try ( :type )
334
+ Marcel :: Magic . by_magic ( file ) . try ( :type )
336
335
end
337
336
338
337
if type . nil?
339
- type = :: MiniMime . lookup_by_filename ( path ) . try ( :content_type )
338
+ type = Marcel :: Magic . by_path ( file ) . try ( :type )
340
339
type = 'invalid/invalid' unless type . nil? || type . start_with? ( 'text/' )
341
340
end
342
341
Original file line number Diff line number Diff line change 378
378
expect ( sanitized_file . content_type ) . to eq ( "application/octet-stream" )
379
379
end
380
380
381
- it "should detect content type correctly using MagicMime when content_type is not set" do
381
+ it "should detect content type correctly using Marcel when content_type is not set" do
382
382
sanitized_file . content_type = nil
383
383
sanitized_file . move_to ( file_path ( "new_dir" , "gurr.png" ) )
384
384
You can’t perform that action at this time.
0 commit comments