carrierwave 1.3.4 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +117 -43
- data/lib/carrierwave/downloader/base.rb +93 -0
- data/lib/carrierwave/downloader/remote_file.rb +65 -0
- data/lib/carrierwave/locale/en.yml +5 -4
- data/lib/carrierwave/mount.rb +25 -19
- data/lib/carrierwave/mounter.rb +70 -47
- data/lib/carrierwave/orm/activerecord.rb +14 -8
- data/lib/carrierwave/processing/mini_magick.rb +100 -117
- data/lib/carrierwave/processing/rmagick.rb +1 -1
- data/lib/carrierwave/processing/vips.rb +284 -0
- data/lib/carrierwave/processing.rb +1 -0
- data/lib/carrierwave/sanitized_file.rb +38 -16
- data/lib/carrierwave/storage/file.rb +2 -2
- data/lib/carrierwave/storage/fog.rb +44 -13
- data/lib/carrierwave/storage.rb +1 -0
- data/lib/carrierwave/uploader/cache.rb +24 -16
- data/lib/carrierwave/uploader/configuration.rb +28 -15
- data/lib/carrierwave/uploader/content_type_blacklist.rb +17 -8
- data/lib/carrierwave/uploader/content_type_whitelist.rb +20 -8
- data/lib/carrierwave/uploader/download.rb +2 -123
- data/lib/carrierwave/uploader/extension_blacklist.rb +18 -10
- data/lib/carrierwave/uploader/extension_whitelist.rb +19 -10
- data/lib/carrierwave/uploader/mountable.rb +6 -0
- data/lib/carrierwave/uploader/processing.rb +11 -1
- data/lib/carrierwave/uploader/proxy.rb +2 -2
- data/lib/carrierwave/uploader/serialization.rb +1 -1
- data/lib/carrierwave/uploader/store.rb +5 -3
- data/lib/carrierwave/uploader/url.rb +6 -3
- data/lib/carrierwave/uploader/versions.rb +43 -13
- data/lib/carrierwave/uploader.rb +0 -9
- data/lib/carrierwave/validations/active_model.rb +3 -3
- data/lib/carrierwave/version.rb +1 -1
- data/lib/carrierwave.rb +4 -0
- data/lib/generators/templates/uploader.rb +2 -2
- metadata +100 -27
@@ -23,7 +23,7 @@ module CarrierWave
|
|
23
23
|
prepend Module.new {
|
24
24
|
def initialize(*)
|
25
25
|
super
|
26
|
-
@versions = nil
|
26
|
+
@versions, @versions_to_cache, @versions_to_store = nil
|
27
27
|
end
|
28
28
|
}
|
29
29
|
end
|
@@ -220,16 +220,18 @@ module CarrierWave
|
|
220
220
|
# Recreate versions and reprocess them. This can be used to recreate
|
221
221
|
# versions if their parameters somehow have changed.
|
222
222
|
#
|
223
|
-
def recreate_versions!(*
|
223
|
+
def recreate_versions!(*names)
|
224
224
|
# Some files could possibly not be stored on the local disk. This
|
225
225
|
# doesn't play nicely with processing. Make sure that we're only
|
226
226
|
# processing a cached file
|
227
227
|
#
|
228
228
|
# The call to store! will trigger the necessary callbacks to both
|
229
229
|
# process this version and all sub-versions
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
|
231
|
+
if names.any?
|
232
|
+
set_versions_to_cache_and_store(names)
|
233
|
+
store!(file)
|
234
|
+
reset_versions_to_cache_and_store
|
233
235
|
else
|
234
236
|
cache! if !cached?
|
235
237
|
store!
|
@@ -237,6 +239,39 @@ module CarrierWave
|
|
237
239
|
end
|
238
240
|
|
239
241
|
private
|
242
|
+
|
243
|
+
def set_versions_to_cache_and_store(names)
|
244
|
+
@versions_to_cache = source_versions_of(names)
|
245
|
+
@versions_to_store = active_versions_with_names_in(@versions_to_cache + names)
|
246
|
+
end
|
247
|
+
|
248
|
+
def reset_versions_to_cache_and_store
|
249
|
+
@versions_to_cache, @versions_to_store = nil, nil
|
250
|
+
end
|
251
|
+
|
252
|
+
def versions_to_cache
|
253
|
+
@versions_to_cache || dependent_versions
|
254
|
+
end
|
255
|
+
|
256
|
+
def versions_to_store
|
257
|
+
@versions_to_store || active_versions
|
258
|
+
end
|
259
|
+
|
260
|
+
def source_versions_of(requested_names)
|
261
|
+
versions.inject([]) do |sources, (name, uploader)|
|
262
|
+
next sources unless requested_names.include?(name)
|
263
|
+
next sources unless source_name = uploader.class.version_options[:from_version]
|
264
|
+
|
265
|
+
sources << [source_name, versions[source_name]]
|
266
|
+
end.uniq
|
267
|
+
end
|
268
|
+
|
269
|
+
def active_versions_with_names_in(names)
|
270
|
+
active_versions.select do |pretendent_name, uploader|
|
271
|
+
names.include?(pretendent_name)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
240
275
|
def assign_parent_cache_id(file)
|
241
276
|
active_versions.each do |name, uploader|
|
242
277
|
uploader.parent_cache_id = @cache_id
|
@@ -270,19 +305,14 @@ module CarrierWave
|
|
270
305
|
end
|
271
306
|
|
272
307
|
def cache_versions!(new_file)
|
273
|
-
|
308
|
+
versions_to_cache.each do |name, v|
|
274
309
|
v.send(:cache_id=, @cache_id)
|
275
310
|
v.cache!(new_file)
|
276
311
|
end
|
277
312
|
end
|
278
313
|
|
279
|
-
def store_versions!(new_file
|
280
|
-
|
281
|
-
active = Hash[active_versions]
|
282
|
-
versions.each { |v| active[v].try(:store!, new_file) } unless active.empty?
|
283
|
-
else
|
284
|
-
active_versions.each { |name, v| v.store!(new_file) }
|
285
|
-
end
|
314
|
+
def store_versions!(new_file)
|
315
|
+
versions_to_store.each { |name, v| v.store!(new_file) }
|
286
316
|
end
|
287
317
|
|
288
318
|
def remove_versions!
|
data/lib/carrierwave/uploader.rb
CHANGED
@@ -43,15 +43,6 @@ module CarrierWave
|
|
43
43
|
class Base
|
44
44
|
attr_reader :file
|
45
45
|
|
46
|
-
##
|
47
|
-
# Workaround for class_attribute malfunction when used with Module#prepend
|
48
|
-
#
|
49
|
-
if RUBY_VERSION < '2.1.0'
|
50
|
-
def self.singleton_class?
|
51
|
-
!ancestors.include? self
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
46
|
include CarrierWave::Uploader::Configuration
|
56
47
|
include CarrierWave::Uploader::Callbacks
|
57
48
|
include CarrierWave::Uploader::Proxy
|
@@ -11,7 +11,7 @@ module CarrierWave
|
|
11
11
|
class ProcessingValidator < ::ActiveModel::EachValidator
|
12
12
|
|
13
13
|
def validate_each(record, attribute, value)
|
14
|
-
|
14
|
+
record.__send__("#{attribute}_processing_errors").each do |e|
|
15
15
|
message = (e.message == e.class.to_s) ? :carrierwave_processing_error : e.message
|
16
16
|
record.errors.add(attribute, message)
|
17
17
|
end
|
@@ -21,7 +21,7 @@ module CarrierWave
|
|
21
21
|
class IntegrityValidator < ::ActiveModel::EachValidator
|
22
22
|
|
23
23
|
def validate_each(record, attribute, value)
|
24
|
-
|
24
|
+
record.__send__("#{attribute}_integrity_errors").each do |e|
|
25
25
|
message = (e.message == e.class.to_s) ? :carrierwave_integrity_error : e.message
|
26
26
|
record.errors.add(attribute, message)
|
27
27
|
end
|
@@ -31,7 +31,7 @@ module CarrierWave
|
|
31
31
|
class DownloadValidator < ::ActiveModel::EachValidator
|
32
32
|
|
33
33
|
def validate_each(record, attribute, value)
|
34
|
-
|
34
|
+
record.__send__("#{attribute}_download_errors").each do |e|
|
35
35
|
message = (e.message == e.class.to_s) ? :carrierwave_download_error : e.message
|
36
36
|
record.errors.add(attribute, message)
|
37
37
|
end
|
data/lib/carrierwave/version.rb
CHANGED
data/lib/carrierwave.rb
CHANGED
@@ -33,9 +33,9 @@ class <%= class_name %>Uploader < CarrierWave::Uploader::Base
|
|
33
33
|
# process resize_to_fit: [50, 50]
|
34
34
|
# end
|
35
35
|
|
36
|
-
# Add
|
36
|
+
# Add an allowlist of extensions which are allowed to be uploaded.
|
37
37
|
# For images you might use something like this:
|
38
|
-
# def
|
38
|
+
# def extension_allowlist
|
39
39
|
# %w(jpg jpeg gif png)
|
40
40
|
# end
|
41
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,62 +16,112 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mini_mime
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: image_processing
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.1
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
62
66
|
- - "~>"
|
63
67
|
- !ruby/object:Gem::Version
|
64
|
-
version: '1.
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: marcel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.0
|
65
76
|
type: :runtime
|
66
77
|
prerelease: false
|
67
78
|
version_requirements: !ruby/object:Gem::Requirement
|
68
79
|
requirements:
|
69
|
-
- - "
|
80
|
+
- - "~>"
|
70
81
|
- !ruby/object:Gem::Version
|
71
|
-
version: 1.
|
82
|
+
version: 1.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: addressable
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ssrf_filter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
72
108
|
- - "~>"
|
73
109
|
- !ruby/object:Gem::Version
|
74
110
|
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pg
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
75
125
|
- !ruby/object:Gem::Dependency
|
76
126
|
name: rails
|
77
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +165,7 @@ dependencies:
|
|
115
165
|
- !ruby/object:Gem::Version
|
116
166
|
version: '3.4'
|
117
167
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
168
|
+
name: rspec-retry
|
119
169
|
requirement: !ruby/object:Gem::Requirement
|
120
170
|
requirements:
|
121
171
|
- - ">="
|
@@ -129,19 +179,19 @@ dependencies:
|
|
129
179
|
- !ruby/object:Gem::Version
|
130
180
|
version: '0'
|
131
181
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
182
|
+
name: webmock
|
133
183
|
requirement: !ruby/object:Gem::Requirement
|
134
184
|
requirements:
|
135
|
-
- - "
|
185
|
+
- - ">="
|
136
186
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
187
|
+
version: '0'
|
138
188
|
type: :development
|
139
189
|
prerelease: false
|
140
190
|
version_requirements: !ruby/object:Gem::Requirement
|
141
191
|
requirements:
|
142
|
-
- - "
|
192
|
+
- - ">="
|
143
193
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
194
|
+
version: '0'
|
145
195
|
- !ruby/object:Gem::Dependency
|
146
196
|
name: fog-aws
|
147
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,16 +210,22 @@ dependencies:
|
|
160
210
|
name: fog-google
|
161
211
|
requirement: !ruby/object:Gem::Requirement
|
162
212
|
requirements:
|
163
|
-
- - "
|
213
|
+
- - "~>"
|
164
214
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
215
|
+
version: '1.7'
|
216
|
+
- - "!="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: 1.12.1
|
166
219
|
type: :development
|
167
220
|
prerelease: false
|
168
221
|
version_requirements: !ruby/object:Gem::Requirement
|
169
222
|
requirements:
|
170
|
-
- - "
|
223
|
+
- - "~>"
|
171
224
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
225
|
+
version: '1.7'
|
226
|
+
- - "!="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 1.12.1
|
173
229
|
- !ruby/object:Gem::Dependency
|
174
230
|
name: fog-local
|
175
231
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,6 +324,20 @@ dependencies:
|
|
268
324
|
- - ">="
|
269
325
|
- !ruby/object:Gem::Version
|
270
326
|
version: '0'
|
327
|
+
- !ruby/object:Gem::Dependency
|
328
|
+
name: pry-byebug
|
329
|
+
requirement: !ruby/object:Gem::Requirement
|
330
|
+
requirements:
|
331
|
+
- - ">="
|
332
|
+
- !ruby/object:Gem::Version
|
333
|
+
version: '0'
|
334
|
+
type: :development
|
335
|
+
prerelease: false
|
336
|
+
version_requirements: !ruby/object:Gem::Requirement
|
337
|
+
requirements:
|
338
|
+
- - ">="
|
339
|
+
- !ruby/object:Gem::Version
|
340
|
+
version: '0'
|
271
341
|
description: Upload files in your Ruby applications, map them to a range of ORMs,
|
272
342
|
store them on different backends.
|
273
343
|
email:
|
@@ -280,6 +350,8 @@ files:
|
|
280
350
|
- README.md
|
281
351
|
- lib/carrierwave.rb
|
282
352
|
- lib/carrierwave/compatibility/paperclip.rb
|
353
|
+
- lib/carrierwave/downloader/base.rb
|
354
|
+
- lib/carrierwave/downloader/remote_file.rb
|
283
355
|
- lib/carrierwave/error.rb
|
284
356
|
- lib/carrierwave/locale/en.yml
|
285
357
|
- lib/carrierwave/mount.rb
|
@@ -288,6 +360,7 @@ files:
|
|
288
360
|
- lib/carrierwave/processing.rb
|
289
361
|
- lib/carrierwave/processing/mini_magick.rb
|
290
362
|
- lib/carrierwave/processing/rmagick.rb
|
363
|
+
- lib/carrierwave/processing/vips.rb
|
291
364
|
- lib/carrierwave/sanitized_file.rb
|
292
365
|
- lib/carrierwave/storage.rb
|
293
366
|
- lib/carrierwave/storage/abstract.rb
|
@@ -332,14 +405,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
332
405
|
requirements:
|
333
406
|
- - ">="
|
334
407
|
- !ruby/object:Gem::Version
|
335
|
-
version: 2.
|
408
|
+
version: 2.2.2
|
336
409
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
410
|
requirements:
|
338
411
|
- - ">="
|
339
412
|
- !ruby/object:Gem::Version
|
340
413
|
version: '0'
|
341
414
|
requirements: []
|
342
|
-
rubygems_version: 3.4.
|
415
|
+
rubygems_version: 3.4.10
|
343
416
|
signing_key:
|
344
417
|
specification_version: 4
|
345
418
|
summary: Ruby file upload library
|