paperclip 4.3.7 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +17 -0
- data/.github/issue_template.md +3 -0
- data/.hound.yml +5 -16
- data/.travis.yml +15 -12
- data/Appraisals +4 -8
- data/CONTRIBUTING.md +16 -5
- data/Gemfile +3 -8
- data/LICENSE +1 -1
- data/MIGRATING-ES.md +317 -0
- data/MIGRATING.md +375 -0
- data/NEWS +126 -31
- data/README.md +264 -156
- data/Rakefile +1 -1
- data/UPGRADING +12 -9
- data/features/basic_integration.feature +3 -2
- data/features/migration.feature +0 -24
- data/features/step_definitions/attachment_steps.rb +14 -14
- data/features/step_definitions/rails_steps.rb +29 -28
- data/features/step_definitions/s3_steps.rb +2 -2
- data/features/support/env.rb +1 -0
- data/features/support/paths.rb +1 -1
- data/features/support/rails.rb +0 -24
- data/gemfiles/4.2.gemfile +3 -5
- data/gemfiles/{3.2.gemfile → 5.0.gemfile} +4 -6
- data/lib/generators/paperclip/paperclip_generator.rb +9 -1
- data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +1 -1
- data/lib/paperclip.rb +14 -12
- data/lib/paperclip/attachment.rb +44 -20
- data/lib/paperclip/attachment_registry.rb +2 -1
- data/lib/paperclip/callbacks.rb +8 -6
- data/lib/paperclip/content_type_detector.rb +3 -2
- data/lib/paperclip/errors.rb +3 -1
- data/lib/paperclip/file_command_content_type_detector.rb +1 -1
- data/lib/paperclip/filename_cleaner.rb +0 -1
- data/lib/paperclip/geometry_detector_factory.rb +3 -3
- data/lib/paperclip/glue.rb +1 -1
- data/lib/paperclip/has_attached_file.rb +7 -1
- data/lib/paperclip/helpers.rb +15 -11
- data/lib/paperclip/interpolations.rb +7 -2
- data/lib/paperclip/io_adapters/abstract_adapter.rb +31 -4
- data/lib/paperclip/io_adapters/attachment_adapter.rb +17 -6
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +8 -8
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +5 -4
- data/lib/paperclip/io_adapters/file_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +8 -7
- data/lib/paperclip/io_adapters/identity_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/nil_adapter.rb +8 -5
- data/lib/paperclip/io_adapters/registry.rb +6 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +9 -6
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +10 -6
- data/lib/paperclip/io_adapters/uri_adapter.rb +22 -17
- data/lib/paperclip/logger.rb +1 -1
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +4 -4
- data/lib/paperclip/media_type_spoof_detector.rb +11 -7
- data/lib/paperclip/processor.rb +15 -6
- data/lib/paperclip/schema.rb +3 -9
- data/lib/paperclip/storage/filesystem.rb +13 -2
- data/lib/paperclip/storage/fog.rb +21 -14
- data/lib/paperclip/storage/s3.rb +81 -61
- data/lib/paperclip/style.rb +0 -1
- data/lib/paperclip/thumbnail.rb +22 -9
- data/lib/paperclip/url_generator.rb +17 -13
- data/lib/paperclip/validators.rb +1 -1
- data/lib/paperclip/validators/attachment_size_validator.rb +1 -7
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +4 -0
- data/lib/paperclip/version.rb +3 -1
- data/lib/tasks/paperclip.rake +18 -4
- data/paperclip.gemspec +13 -10
- data/spec/paperclip/attachment_processing_spec.rb +2 -5
- data/spec/paperclip/attachment_registry_spec.rb +28 -0
- data/spec/paperclip/attachment_spec.rb +89 -20
- data/spec/paperclip/content_type_detector_spec.rb +1 -1
- data/spec/paperclip/file_command_content_type_detector_spec.rb +15 -1
- data/spec/paperclip/filename_cleaner_spec.rb +0 -1
- data/spec/paperclip/has_attached_file_spec.rb +24 -8
- data/spec/paperclip/integration_spec.rb +42 -5
- data/spec/paperclip/interpolations_spec.rb +9 -0
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +104 -22
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +6 -3
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +7 -1
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +2 -2
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +47 -13
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/registry_spec.rb +2 -2
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +5 -5
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +104 -11
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +10 -0
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +1 -1
- data/spec/paperclip/media_type_spoof_detector_spec.rb +41 -0
- data/spec/paperclip/paperclip_spec.rb +15 -45
- data/spec/paperclip/processor_spec.rb +4 -4
- data/spec/paperclip/schema_spec.rb +46 -46
- data/spec/paperclip/storage/fog_spec.rb +31 -0
- data/spec/paperclip/storage/s3_live_spec.rb +20 -14
- data/spec/paperclip/storage/s3_spec.rb +359 -192
- data/spec/paperclip/style_spec.rb +0 -1
- data/spec/paperclip/tempfile_spec.rb +35 -0
- data/spec/paperclip/thumbnail_spec.rb +43 -38
- data/spec/paperclip/url_generator_spec.rb +54 -44
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +26 -20
- data/spec/paperclip/validators_spec.rb +5 -5
- data/spec/spec_helper.rb +5 -2
- data/spec/support/assertions.rb +12 -1
- data/spec/support/mock_attachment.rb +2 -0
- data/spec/support/mock_url_generator_builder.rb +2 -2
- data/spec/support/model_reconstruction.rb +11 -3
- data/spec/support/reporting.rb +11 -0
- metadata +64 -61
- data/cucumber/paperclip_steps.rb +0 -6
- data/gemfiles/4.1.gemfile +0 -19
- data/lib/paperclip/deprecations.rb +0 -42
- data/lib/paperclip/locales/de.yml +0 -18
- data/lib/paperclip/locales/es.yml +0 -18
- data/lib/paperclip/locales/ja.yml +0 -18
- data/lib/paperclip/locales/pt-BR.yml +0 -18
- data/lib/paperclip/locales/zh-CN.yml +0 -18
- data/lib/paperclip/locales/zh-HK.yml +0 -18
- data/lib/paperclip/locales/zh-TW.yml +0 -18
- data/spec/paperclip/deprecations_spec.rb +0 -65
- data/spec/support/deprecations.rb +0 -9
- data/spec/support/rails_helpers.rb +0 -7
@@ -1,22 +1,22 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class DataUriAdapter < StringioAdapter
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
String === target && target =~ REGEXP
|
6
|
+
end
|
7
|
+
end
|
3
8
|
|
4
9
|
REGEXP = /\Adata:([-\w]+\/[-\w\+\.]+)?;base64,(.*)/m
|
5
10
|
|
6
|
-
def initialize(target_uri)
|
7
|
-
super(extract_target(target_uri))
|
11
|
+
def initialize(target_uri, options = {})
|
12
|
+
super(extract_target(target_uri), options)
|
8
13
|
end
|
9
14
|
|
10
15
|
private
|
11
16
|
|
12
17
|
def extract_target(uri)
|
13
18
|
data_uri_parts = uri.match(REGEXP) || []
|
14
|
-
StringIO.new(Base64.decode64(data_uri_parts[2] ||
|
19
|
+
StringIO.new(Base64.decode64(data_uri_parts[2] || ""))
|
15
20
|
end
|
16
|
-
|
17
21
|
end
|
18
22
|
end
|
19
|
-
|
20
|
-
Paperclip.io_adapters.register Paperclip::DataUriAdapter do |target|
|
21
|
-
String === target && target =~ Paperclip::DataUriAdapter::REGEXP
|
22
|
-
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class EmptyStringAdapter < AbstractAdapter
|
3
|
-
def
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
target.is_a?(String) && target.empty?
|
6
|
+
end
|
4
7
|
end
|
5
8
|
|
6
9
|
def nil?
|
@@ -13,6 +16,4 @@ module Paperclip
|
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
|
-
Paperclip.
|
17
|
-
target.is_a?(String) && target.empty?
|
18
|
-
end
|
19
|
+
Paperclip::EmptyStringAdapter.register
|
@@ -1,14 +1,22 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class FileAdapter < AbstractAdapter
|
3
|
-
def
|
4
|
-
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
File === target || ::Tempfile === target
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(target, options = {})
|
10
|
+
super
|
5
11
|
cache_current_values
|
6
12
|
end
|
7
13
|
|
8
14
|
private
|
9
15
|
|
10
16
|
def cache_current_values
|
11
|
-
|
17
|
+
if @target.respond_to?(:original_filename)
|
18
|
+
self.original_filename = @target.original_filename
|
19
|
+
end
|
12
20
|
self.original_filename ||= File.basename(@target.path)
|
13
21
|
@tempfile = copy_to_tempfile(@target)
|
14
22
|
@content_type = ContentTypeDetector.new(@target.path).detect
|
@@ -17,6 +25,4 @@ module Paperclip
|
|
17
25
|
end
|
18
26
|
end
|
19
27
|
|
20
|
-
Paperclip.
|
21
|
-
File === target || Tempfile === target
|
22
|
-
end
|
28
|
+
Paperclip::FileAdapter.register
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class HttpUrlProxyAdapter < UriAdapter
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
String === target && target =~ REGEXP
|
6
|
+
end
|
7
|
+
end
|
3
8
|
|
4
9
|
REGEXP = /\Ahttps?:\/\//
|
5
10
|
|
6
|
-
def initialize(target)
|
7
|
-
|
11
|
+
def initialize(target, options = {})
|
12
|
+
escaped = URI.escape(target)
|
13
|
+
super(URI(target == URI.unescape(target) ? escaped : target), options)
|
8
14
|
end
|
9
|
-
|
10
15
|
end
|
11
16
|
end
|
12
|
-
|
13
|
-
Paperclip.io_adapters.register Paperclip::HttpUrlProxyAdapter do |target|
|
14
|
-
String === target && target =~ Paperclip::HttpUrlProxyAdapter::REGEXP
|
15
|
-
end
|
@@ -1,12 +1,18 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class IdentityAdapter < AbstractAdapter
|
3
|
-
def
|
4
|
-
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register Paperclip::IdentityAdapter.new do |target|
|
5
|
+
Paperclip.io_adapters.registered?(target)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize
|
5
10
|
end
|
6
|
-
end
|
7
|
-
end
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
def new(target, _)
|
13
|
+
target
|
14
|
+
end
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
18
|
+
Paperclip::IdentityAdapter.register
|
@@ -1,8 +1,13 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class NilAdapter < AbstractAdapter
|
3
|
-
def
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
target.nil? || ((Paperclip::Attachment === target) && !target.present?)
|
6
|
+
end
|
4
7
|
end
|
5
8
|
|
9
|
+
def initialize(_target, _options = {}); end
|
10
|
+
|
6
11
|
def original_filename
|
7
12
|
""
|
8
13
|
end
|
@@ -19,7 +24,7 @@ module Paperclip
|
|
19
24
|
true
|
20
25
|
end
|
21
26
|
|
22
|
-
def read(*
|
27
|
+
def read(*_args)
|
23
28
|
nil
|
24
29
|
end
|
25
30
|
|
@@ -29,6 +34,4 @@ module Paperclip
|
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
|
-
Paperclip.
|
33
|
-
target.nil? || ( (Paperclip::Attachment === target) && !target.present? )
|
34
|
-
end
|
37
|
+
Paperclip::NilAdapter.register
|
@@ -12,6 +12,10 @@ module Paperclip
|
|
12
12
|
@registered_handlers << [block, handler_class]
|
13
13
|
end
|
14
14
|
|
15
|
+
def unregister(handler_class)
|
16
|
+
@registered_handlers.reject! { |_, klass| klass == handler_class }
|
17
|
+
end
|
18
|
+
|
15
19
|
def handler_for(target)
|
16
20
|
@registered_handlers.each do |tester, handler|
|
17
21
|
return handler if tester.call(target)
|
@@ -25,8 +29,8 @@ module Paperclip
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
def for(target)
|
29
|
-
handler_for(target).new(target)
|
32
|
+
def for(target, options = {})
|
33
|
+
handler_for(target).new(target, options)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class StringioAdapter < AbstractAdapter
|
3
|
-
def
|
4
|
-
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
StringIO === target
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(target, options = {})
|
10
|
+
super
|
5
11
|
cache_current_values
|
6
12
|
end
|
7
13
|
|
@@ -24,10 +30,7 @@ module Paperclip
|
|
24
30
|
destination.rewind
|
25
31
|
destination
|
26
32
|
end
|
27
|
-
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
|
-
Paperclip.
|
32
|
-
StringIO === target
|
33
|
-
end
|
36
|
+
Paperclip::StringioAdapter.register
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module Paperclip
|
2
2
|
class UploadedFileAdapter < AbstractAdapter
|
3
|
-
def
|
4
|
-
|
3
|
+
def self.register
|
4
|
+
Paperclip.io_adapters.register self do |target|
|
5
|
+
target.class.name.include?("UploadedFile")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(target, options = {})
|
10
|
+
super
|
5
11
|
cache_current_values
|
6
12
|
|
7
13
|
if @target.respond_to?(:tempfile)
|
@@ -24,7 +30,7 @@ module Paperclip
|
|
24
30
|
end
|
25
31
|
|
26
32
|
def content_type_detector
|
27
|
-
self.class.content_type_detector
|
33
|
+
self.class.content_type_detector || Paperclip::ContentTypeDetector
|
28
34
|
end
|
29
35
|
|
30
36
|
def determine_content_type
|
@@ -37,6 +43,4 @@ module Paperclip
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
|
-
Paperclip.
|
41
|
-
target.class.name.include?("UploadedFile")
|
42
|
-
end
|
46
|
+
Paperclip::UploadedFileAdapter.register
|
@@ -1,11 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require "open-uri"
|
2
2
|
|
3
3
|
module Paperclip
|
4
4
|
class UriAdapter < AbstractAdapter
|
5
5
|
attr_writer :content_type
|
6
6
|
|
7
|
-
def
|
8
|
-
|
7
|
+
def self.register
|
8
|
+
Paperclip.io_adapters.register self do |target|
|
9
|
+
target.is_a?(URI)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(target, options = {})
|
14
|
+
super
|
9
15
|
@content = download_content
|
10
16
|
cache_current_values
|
11
17
|
@tempfile = copy_to_tempfile(@content)
|
@@ -17,21 +23,22 @@ module Paperclip
|
|
17
23
|
self.content_type = content_type_from_content || "text/html"
|
18
24
|
|
19
25
|
self.original_filename = filename_from_content_disposition ||
|
20
|
-
filename_from_path ||
|
21
|
-
default_filename
|
26
|
+
filename_from_path || default_filename
|
22
27
|
@size = @content.size
|
23
28
|
end
|
24
29
|
|
25
30
|
def content_type_from_content
|
26
|
-
|
27
|
-
@content.content_type
|
28
|
-
end
|
31
|
+
@content.meta["content-type"].presence
|
29
32
|
end
|
30
33
|
|
31
34
|
def filename_from_content_disposition
|
32
|
-
if @content.meta.
|
33
|
-
|
34
|
-
|
35
|
+
if @content.meta.key?("content-disposition") && @content.meta["content-disposition"].match(/filename/i)
|
36
|
+
# can include both filename and filename* values according to RCF6266. filename should come first
|
37
|
+
_, filename = @content.meta["content-disposition"].split(/filename\*?\s*=\s*/i)
|
38
|
+
|
39
|
+
# filename can be enclosed in quotes or not
|
40
|
+
matches = filename.match(/"(.*)"/)
|
41
|
+
matches ? matches[1] : filename.split(';')[0]
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -44,11 +51,13 @@ module Paperclip
|
|
44
51
|
end
|
45
52
|
|
46
53
|
def download_content
|
47
|
-
|
54
|
+
options = { read_timeout: Paperclip.options[:read_timeout] }.compact
|
55
|
+
|
56
|
+
open(@target, **options)
|
48
57
|
end
|
49
58
|
|
50
59
|
def copy_to_tempfile(src)
|
51
|
-
while data = src.read(16*1024)
|
60
|
+
while data = src.read(16 * 1024)
|
52
61
|
destination.write(data)
|
53
62
|
end
|
54
63
|
src.close
|
@@ -57,7 +66,3 @@ module Paperclip
|
|
57
66
|
end
|
58
67
|
end
|
59
68
|
end
|
60
|
-
|
61
|
-
Paperclip.io_adapters.register Paperclip::UriAdapter do |target|
|
62
|
-
target.kind_of?(URI)
|
63
|
-
end
|
data/lib/paperclip/logger.rb
CHANGED
@@ -40,9 +40,9 @@ module Paperclip
|
|
40
40
|
|
41
41
|
def failure_message
|
42
42
|
"#{expected_attachment}\n".tap do |message|
|
43
|
-
message << accepted_types_and_failures
|
43
|
+
message << accepted_types_and_failures.to_s
|
44
44
|
message << "\n\n" if @allowed_types.present? && @rejected_types.present?
|
45
|
-
message << rejected_types_and_failures
|
45
|
+
message << rejected_types_and_failures.to_s
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -55,7 +55,7 @@ module Paperclip
|
|
55
55
|
def accepted_types_and_failures
|
56
56
|
if @allowed_types.present?
|
57
57
|
"Accept content types: #{@allowed_types.join(", ")}\n".tap do |message|
|
58
|
-
if @missing_allowed_types.
|
58
|
+
if @missing_allowed_types.present?
|
59
59
|
message << " #{@missing_allowed_types.join(", ")} were rejected."
|
60
60
|
else
|
61
61
|
message << " All were accepted successfully."
|
@@ -66,7 +66,7 @@ module Paperclip
|
|
66
66
|
def rejected_types_and_failures
|
67
67
|
if @rejected_types.present?
|
68
68
|
"Reject content types: #{@rejected_types.join(", ")}\n".tap do |message|
|
69
|
-
if @missing_rejected_types.
|
69
|
+
if @missing_rejected_types.present?
|
70
70
|
message << " #{@missing_rejected_types.join(", ")} were accepted."
|
71
71
|
else
|
72
72
|
message << " All were rejected successfully."
|
@@ -11,7 +11,7 @@ module Paperclip
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def spoofed?
|
14
|
-
if has_name? &&
|
14
|
+
if has_name? && media_type_mismatch? && mapping_override_mismatch?
|
15
15
|
Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_content_type} from Headers, #{content_types_from_name.map(&:to_s)} from Extension), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.")
|
16
16
|
true
|
17
17
|
else
|
@@ -30,15 +30,18 @@ module Paperclip
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def media_type_mismatch?
|
33
|
-
|
33
|
+
extension_type_mismatch? || calculated_type_mismatch?
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
supplied_media_type.present? &&
|
36
|
+
def extension_type_mismatch?
|
37
|
+
supplied_media_type.present? &&
|
38
|
+
has_extension? &&
|
39
|
+
!media_types_from_name.include?(supplied_media_type)
|
38
40
|
end
|
39
41
|
|
40
42
|
def calculated_type_mismatch?
|
41
|
-
|
43
|
+
supplied_media_type.present? &&
|
44
|
+
!calculated_content_type.include?(supplied_media_type)
|
42
45
|
end
|
43
46
|
|
44
47
|
def mapping_override_mismatch?
|
@@ -72,8 +75,9 @@ module Paperclip
|
|
72
75
|
|
73
76
|
def type_from_file_command
|
74
77
|
begin
|
75
|
-
Paperclip.run("file", "-b --mime :file", :
|
76
|
-
|
78
|
+
Paperclip.run("file", "-b --mime :file", file: @file.path).
|
79
|
+
split(/[:;\s]+/).first
|
80
|
+
rescue Terrapin::CommandLineError
|
77
81
|
""
|
78
82
|
end
|
79
83
|
end
|
data/lib/paperclip/processor.rb
CHANGED
@@ -7,13 +7,14 @@ module Paperclip
|
|
7
7
|
# Processors are required to be defined inside the Paperclip module and
|
8
8
|
# are also required to be a subclass of Paperclip::Processor. There is
|
9
9
|
# only one method you *must* implement to properly be a subclass:
|
10
|
-
# #make, but #initialize may also be of use.
|
10
|
+
# #make, but #initialize may also be of use. #initialize accepts 3
|
11
11
|
# arguments: the file that will be operated on (which is an instance of
|
12
12
|
# File), a hash of options that were defined in has_attached_file's
|
13
|
-
# style hash, and the Paperclip::Attachment itself.
|
13
|
+
# style hash, and the Paperclip::Attachment itself. These are set as
|
14
|
+
# instance variables that can be used within `#make`.
|
14
15
|
#
|
15
|
-
#
|
16
|
-
#
|
16
|
+
# #make must return an instance of File (Tempfile is acceptable) which
|
17
|
+
# contains the results of the processing.
|
17
18
|
#
|
18
19
|
# See Paperclip.run for more information about using command-line
|
19
20
|
# utilities from within Processors.
|
@@ -36,13 +37,21 @@ module Paperclip
|
|
36
37
|
# The convert method runs the convert binary with the provided arguments.
|
37
38
|
# See Paperclip.run for the available options.
|
38
39
|
def convert(arguments = "", local_options = {})
|
39
|
-
Paperclip.run(
|
40
|
+
Paperclip.run(
|
41
|
+
Paperclip.options[:is_windows] ? "magick convert" : "convert",
|
42
|
+
arguments,
|
43
|
+
local_options,
|
44
|
+
)
|
40
45
|
end
|
41
46
|
|
42
47
|
# The identify method runs the identify binary with the provided arguments.
|
43
48
|
# See Paperclip.run for the available options.
|
44
49
|
def identify(arguments = "", local_options = {})
|
45
|
-
Paperclip.run(
|
50
|
+
Paperclip.run(
|
51
|
+
Paperclip.options[:is_windows] ? "magick identify" : "identify",
|
52
|
+
arguments,
|
53
|
+
local_options,
|
54
|
+
)
|
46
55
|
end
|
47
56
|
end
|
48
57
|
end
|