activestorage 6.0.6.1 → 6.1.7.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activestorage might be problematic. Click here for more details.

Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +230 -167
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +35 -3
  5. data/app/controllers/active_storage/base_controller.rb +11 -0
  6. data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -0
  7. data/app/controllers/active_storage/{blobs_controller.rb → blobs/redirect_controller.rb} +2 -2
  8. data/app/controllers/active_storage/direct_uploads_controller.rb +1 -1
  9. data/app/controllers/active_storage/disk_controller.rb +8 -20
  10. data/app/controllers/active_storage/representations/base_controller.rb +14 -0
  11. data/app/controllers/active_storage/representations/proxy_controller.rb +13 -0
  12. data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +2 -4
  13. data/app/controllers/concerns/active_storage/file_server.rb +18 -0
  14. data/app/controllers/concerns/active_storage/set_blob.rb +1 -1
  15. data/app/controllers/concerns/active_storage/set_current.rb +2 -2
  16. data/app/controllers/concerns/active_storage/set_headers.rb +12 -0
  17. data/app/jobs/active_storage/mirror_job.rb +15 -0
  18. data/app/models/active_storage/attachment.rb +19 -11
  19. data/app/models/active_storage/blob/analyzable.rb +6 -2
  20. data/app/models/active_storage/blob/identifiable.rb +7 -6
  21. data/app/models/active_storage/blob/representable.rb +34 -4
  22. data/app/models/active_storage/blob.rb +122 -57
  23. data/app/models/active_storage/preview.rb +31 -10
  24. data/app/models/active_storage/record.rb +7 -0
  25. data/app/models/active_storage/variant.rb +31 -44
  26. data/app/models/active_storage/variant_record.rb +8 -0
  27. data/app/models/active_storage/variant_with_record.rb +54 -0
  28. data/app/models/active_storage/variation.rb +26 -21
  29. data/config/routes.rb +58 -8
  30. data/db/migrate/20170806125915_create_active_storage_tables.rb +30 -9
  31. data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +21 -0
  32. data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +26 -0
  33. data/lib/active_storage/analyzer/image_analyzer.rb +3 -0
  34. data/lib/active_storage/analyzer/null_analyzer.rb +4 -0
  35. data/lib/active_storage/analyzer/video_analyzer.rb +14 -3
  36. data/lib/active_storage/analyzer.rb +6 -0
  37. data/lib/active_storage/attached/changes/create_many.rb +1 -0
  38. data/lib/active_storage/attached/changes/create_one.rb +17 -4
  39. data/lib/active_storage/attached/many.rb +4 -3
  40. data/lib/active_storage/attached/model.rb +67 -14
  41. data/lib/active_storage/attached/one.rb +4 -3
  42. data/lib/active_storage/engine.rb +41 -43
  43. data/lib/active_storage/errors.rb +3 -0
  44. data/lib/active_storage/gem_version.rb +3 -3
  45. data/lib/active_storage/log_subscriber.rb +6 -0
  46. data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
  47. data/lib/active_storage/previewer/poppler_pdf_previewer.rb +2 -2
  48. data/lib/active_storage/previewer/video_previewer.rb +5 -3
  49. data/lib/active_storage/previewer.rb +13 -3
  50. data/lib/active_storage/service/azure_storage_service.rb +40 -35
  51. data/lib/active_storage/service/configurator.rb +3 -1
  52. data/lib/active_storage/service/disk_service.rb +36 -31
  53. data/lib/active_storage/service/gcs_service.rb +18 -16
  54. data/lib/active_storage/service/mirror_service.rb +31 -7
  55. data/lib/active_storage/service/registry.rb +32 -0
  56. data/lib/active_storage/service/s3_service.rb +51 -23
  57. data/lib/active_storage/service.rb +35 -7
  58. data/lib/active_storage/transformers/image_processing_transformer.rb +21 -308
  59. data/lib/active_storage/transformers/transformer.rb +0 -3
  60. data/lib/active_storage.rb +301 -7
  61. data/lib/tasks/activestorage.rake +5 -1
  62. metadata +54 -17
  63. data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +0 -9
  64. data/lib/active_storage/downloading.rb +0 -47
  65. data/lib/active_storage/transformers/mini_magick_transformer.rb +0 -38
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2017-2019 David Heinemeier Hansson, Basecamp
4
+ # Copyright (c) 2017-2022 David Heinemeier Hansson, Basecamp
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
@@ -52,24 +52,318 @@ module ActiveStorage
52
52
 
53
53
  mattr_accessor :paths, default: {}
54
54
 
55
- mattr_accessor :variable_content_types, default: []
56
- mattr_accessor :binary_content_type, default: "application/octet-stream"
57
- mattr_accessor :content_types_to_serve_as_binary, default: []
58
- mattr_accessor :content_types_allowed_inline, default: []
59
- mattr_accessor :supported_image_processing_methods, default: []
55
+ mattr_accessor :variable_content_types, default: []
56
+ mattr_accessor :web_image_content_types, default: []
57
+ mattr_accessor :binary_content_type, default: "application/octet-stream"
58
+ mattr_accessor :content_types_to_serve_as_binary, default: []
59
+ mattr_accessor :content_types_allowed_inline, default: []
60
+
61
+ mattr_accessor :supported_image_processing_methods, default: [
62
+ "adaptive_blur",
63
+ "adaptive_resize",
64
+ "adaptive_sharpen",
65
+ "adjoin",
66
+ "affine",
67
+ "alpha",
68
+ "annotate",
69
+ "antialias",
70
+ "append",
71
+ "apply",
72
+ "attenuate",
73
+ "authenticate",
74
+ "auto_gamma",
75
+ "auto_level",
76
+ "auto_orient",
77
+ "auto_threshold",
78
+ "backdrop",
79
+ "background",
80
+ "bench",
81
+ "bias",
82
+ "bilateral_blur",
83
+ "black_point_compensation",
84
+ "black_threshold",
85
+ "blend",
86
+ "blue_primary",
87
+ "blue_shift",
88
+ "blur",
89
+ "border",
90
+ "bordercolor",
91
+ "borderwidth",
92
+ "brightness_contrast",
93
+ "cache",
94
+ "canny",
95
+ "caption",
96
+ "channel",
97
+ "channel_fx",
98
+ "charcoal",
99
+ "chop",
100
+ "clahe",
101
+ "clamp",
102
+ "clip",
103
+ "clip_path",
104
+ "clone",
105
+ "clut",
106
+ "coalesce",
107
+ "colorize",
108
+ "colormap",
109
+ "color_matrix",
110
+ "colors",
111
+ "colorspace",
112
+ "colourspace",
113
+ "color_threshold",
114
+ "combine",
115
+ "combine_options",
116
+ "comment",
117
+ "compare",
118
+ "complex",
119
+ "compose",
120
+ "composite",
121
+ "compress",
122
+ "connected_components",
123
+ "contrast",
124
+ "contrast_stretch",
125
+ "convert",
126
+ "convolve",
127
+ "copy",
128
+ "crop",
129
+ "cycle",
130
+ "deconstruct",
131
+ "define",
132
+ "delay",
133
+ "delete",
134
+ "density",
135
+ "depth",
136
+ "descend",
137
+ "deskew",
138
+ "despeckle",
139
+ "direction",
140
+ "displace",
141
+ "dispose",
142
+ "dissimilarity_threshold",
143
+ "dissolve",
144
+ "distort",
145
+ "dither",
146
+ "draw",
147
+ "duplicate",
148
+ "edge",
149
+ "emboss",
150
+ "encoding",
151
+ "endian",
152
+ "enhance",
153
+ "equalize",
154
+ "evaluate",
155
+ "evaluate_sequence",
156
+ "extent",
157
+ "extract",
158
+ "family",
159
+ "features",
160
+ "fft",
161
+ "fill",
162
+ "filter",
163
+ "flatten",
164
+ "flip",
165
+ "floodfill",
166
+ "flop",
167
+ "font",
168
+ "foreground",
169
+ "format",
170
+ "frame",
171
+ "function",
172
+ "fuzz",
173
+ "fx",
174
+ "gamma",
175
+ "gaussian_blur",
176
+ "geometry",
177
+ "gravity",
178
+ "grayscale",
179
+ "green_primary",
180
+ "hald_clut",
181
+ "highlight_color",
182
+ "hough_lines",
183
+ "iconGeometry",
184
+ "iconic",
185
+ "identify",
186
+ "ift",
187
+ "illuminant",
188
+ "immutable",
189
+ "implode",
190
+ "insert",
191
+ "intensity",
192
+ "intent",
193
+ "interlace",
194
+ "interline_spacing",
195
+ "interpolate",
196
+ "interpolative_resize",
197
+ "interword_spacing",
198
+ "kerning",
199
+ "kmeans",
200
+ "kuwahara",
201
+ "label",
202
+ "lat",
203
+ "layers",
204
+ "level",
205
+ "level_colors",
206
+ "limit",
207
+ "limits",
208
+ "linear_stretch",
209
+ "linewidth",
210
+ "liquid_rescale",
211
+ "list",
212
+ "loader",
213
+ "log",
214
+ "loop",
215
+ "lowlight_color",
216
+ "magnify",
217
+ "map",
218
+ "mattecolor",
219
+ "median",
220
+ "mean_shift",
221
+ "metric",
222
+ "mode",
223
+ "modulate",
224
+ "moments",
225
+ "monitor",
226
+ "monochrome",
227
+ "morph",
228
+ "morphology",
229
+ "mosaic",
230
+ "motion_blur",
231
+ "name",
232
+ "negate",
233
+ "noise",
234
+ "normalize",
235
+ "opaque",
236
+ "ordered_dither",
237
+ "orient",
238
+ "page",
239
+ "paint",
240
+ "pause",
241
+ "perceptible",
242
+ "ping",
243
+ "pointsize",
244
+ "polaroid",
245
+ "poly",
246
+ "posterize",
247
+ "precision",
248
+ "preview",
249
+ "process",
250
+ "quality",
251
+ "quantize",
252
+ "quiet",
253
+ "radial_blur",
254
+ "raise",
255
+ "random_threshold",
256
+ "range_threshold",
257
+ "red_primary",
258
+ "regard_warnings",
259
+ "region",
260
+ "remote",
261
+ "render",
262
+ "repage",
263
+ "resample",
264
+ "resize",
265
+ "resize_to_fill",
266
+ "resize_to_fit",
267
+ "resize_to_limit",
268
+ "resize_and_pad",
269
+ "respect_parentheses",
270
+ "reverse",
271
+ "roll",
272
+ "rotate",
273
+ "sample",
274
+ "sampling_factor",
275
+ "saver",
276
+ "scale",
277
+ "scene",
278
+ "screen",
279
+ "seed",
280
+ "segment",
281
+ "selective_blur",
282
+ "separate",
283
+ "sepia_tone",
284
+ "shade",
285
+ "shadow",
286
+ "shared_memory",
287
+ "sharpen",
288
+ "shave",
289
+ "shear",
290
+ "sigmoidal_contrast",
291
+ "silent",
292
+ "similarity_threshold",
293
+ "size",
294
+ "sketch",
295
+ "smush",
296
+ "snaps",
297
+ "solarize",
298
+ "sort_pixels",
299
+ "sparse_color",
300
+ "splice",
301
+ "spread",
302
+ "statistic",
303
+ "stegano",
304
+ "stereo",
305
+ "storage_type",
306
+ "stretch",
307
+ "strip",
308
+ "stroke",
309
+ "strokewidth",
310
+ "style",
311
+ "subimage_search",
312
+ "swap",
313
+ "swirl",
314
+ "synchronize",
315
+ "taint",
316
+ "text_font",
317
+ "threshold",
318
+ "thumbnail",
319
+ "tile_offset",
320
+ "tint",
321
+ "title",
322
+ "transform",
323
+ "transparent",
324
+ "transparent_color",
325
+ "transpose",
326
+ "transverse",
327
+ "treedepth",
328
+ "trim",
329
+ "type",
330
+ "undercolor",
331
+ "unique_colors",
332
+ "units",
333
+ "unsharp",
334
+ "update",
335
+ "valid_image",
336
+ "view",
337
+ "vignette",
338
+ "virtual_pixel",
339
+ "visual",
340
+ "watermark",
341
+ "wave",
342
+ "wavelet_denoise",
343
+ "weight",
344
+ "white_balance",
345
+ "white_point",
346
+ "white_threshold",
347
+ "window",
348
+ "window_group"
349
+ ]
60
350
  mattr_accessor :unsupported_image_processing_arguments
61
351
 
62
352
  mattr_accessor :service_urls_expire_in, default: 5.minutes
63
353
 
64
354
  mattr_accessor :routes_prefix, default: "/rails/active_storage"
355
+ mattr_accessor :draw_routes, default: true
356
+ mattr_accessor :resolve_model_to_route, default: :rails_storage_redirect
65
357
 
66
358
  mattr_accessor :replace_on_assign_to_many, default: false
359
+ mattr_accessor :track_variants, default: false
360
+
361
+ mattr_accessor :video_preview_arguments, default: "-y -vframes 1 -f image2"
67
362
 
68
363
  module Transformers
69
364
  extend ActiveSupport::Autoload
70
365
 
71
366
  autoload :Transformer
72
367
  autoload :ImageProcessingTransformer
73
- autoload :MiniMagickTransformer
74
368
  end
75
369
  end
@@ -17,6 +17,10 @@ namespace :active_storage do
17
17
  task update: :environment do
18
18
  ENV["MIGRATIONS_PATH"] = "db/update_migrate"
19
19
 
20
- Rake::Task["active_storage:install"].invoke
20
+ if Rake::Task.task_defined?("active_storage:install")
21
+ Rake::Task["active_storage:install"].invoke
22
+ else
23
+ Rake::Task["app:active_storage:install"].invoke
24
+ end
21
25
  end
22
26
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.6.1
4
+ version: 6.1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-17 00:00:00.000000000 Z
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.7.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.7.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: actionpack
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - '='
18
32
  - !ruby/object:Gem::Version
19
- version: 6.0.6.1
33
+ version: 6.1.7.6
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - '='
25
39
  - !ruby/object:Gem::Version
26
- version: 6.0.6.1
40
+ version: 6.1.7.6
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activejob
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '='
32
46
  - !ruby/object:Gem::Version
33
- version: 6.0.6.1
47
+ version: 6.1.7.6
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - '='
39
53
  - !ruby/object:Gem::Version
40
- version: 6.0.6.1
54
+ version: 6.1.7.6
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: activerecord
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: 6.0.6.1
61
+ version: 6.1.7.6
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: 6.0.6.1
68
+ version: 6.1.7.6
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: marcel
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mini_mime
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.0
69
97
  description: Attach cloud and local files in Rails applications.
70
98
  email: david@loudthinking.com
71
99
  executables: []
@@ -77,12 +105,17 @@ files:
77
105
  - README.md
78
106
  - app/assets/javascripts/activestorage.js
79
107
  - app/controllers/active_storage/base_controller.rb
80
- - app/controllers/active_storage/blobs_controller.rb
108
+ - app/controllers/active_storage/blobs/proxy_controller.rb
109
+ - app/controllers/active_storage/blobs/redirect_controller.rb
81
110
  - app/controllers/active_storage/direct_uploads_controller.rb
82
111
  - app/controllers/active_storage/disk_controller.rb
83
- - app/controllers/active_storage/representations_controller.rb
112
+ - app/controllers/active_storage/representations/base_controller.rb
113
+ - app/controllers/active_storage/representations/proxy_controller.rb
114
+ - app/controllers/active_storage/representations/redirect_controller.rb
115
+ - app/controllers/concerns/active_storage/file_server.rb
84
116
  - app/controllers/concerns/active_storage/set_blob.rb
85
117
  - app/controllers/concerns/active_storage/set_current.rb
118
+ - app/controllers/concerns/active_storage/set_headers.rb
86
119
  - app/javascript/activestorage/blob_record.js
87
120
  - app/javascript/activestorage/blob_upload.js
88
121
  - app/javascript/activestorage/direct_upload.js
@@ -94,6 +127,7 @@ files:
94
127
  - app/javascript/activestorage/ujs.js
95
128
  - app/jobs/active_storage/analyze_job.rb
96
129
  - app/jobs/active_storage/base_job.rb
130
+ - app/jobs/active_storage/mirror_job.rb
97
131
  - app/jobs/active_storage/purge_job.rb
98
132
  - app/models/active_storage/attachment.rb
99
133
  - app/models/active_storage/blob.rb
@@ -103,11 +137,15 @@ files:
103
137
  - app/models/active_storage/current.rb
104
138
  - app/models/active_storage/filename.rb
105
139
  - app/models/active_storage/preview.rb
140
+ - app/models/active_storage/record.rb
106
141
  - app/models/active_storage/variant.rb
142
+ - app/models/active_storage/variant_record.rb
143
+ - app/models/active_storage/variant_with_record.rb
107
144
  - app/models/active_storage/variation.rb
108
145
  - config/routes.rb
109
146
  - db/migrate/20170806125915_create_active_storage_tables.rb
110
- - db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb
147
+ - db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb
148
+ - db/update_migrate/20191206030411_create_active_storage_variant_records.rb
111
149
  - lib/active_storage.rb
112
150
  - lib/active_storage/analyzer.rb
113
151
  - lib/active_storage/analyzer/image_analyzer.rb
@@ -124,7 +162,6 @@ files:
124
162
  - lib/active_storage/attached/model.rb
125
163
  - lib/active_storage/attached/one.rb
126
164
  - lib/active_storage/downloader.rb
127
- - lib/active_storage/downloading.rb
128
165
  - lib/active_storage/engine.rb
129
166
  - lib/active_storage/errors.rb
130
167
  - lib/active_storage/gem_version.rb
@@ -140,9 +177,9 @@ files:
140
177
  - lib/active_storage/service/disk_service.rb
141
178
  - lib/active_storage/service/gcs_service.rb
142
179
  - lib/active_storage/service/mirror_service.rb
180
+ - lib/active_storage/service/registry.rb
143
181
  - lib/active_storage/service/s3_service.rb
144
182
  - lib/active_storage/transformers/image_processing_transformer.rb
145
- - lib/active_storage/transformers/mini_magick_transformer.rb
146
183
  - lib/active_storage/transformers/transformer.rb
147
184
  - lib/active_storage/version.rb
148
185
  - lib/tasks/activestorage.rake
@@ -151,10 +188,10 @@ licenses:
151
188
  - MIT
152
189
  metadata:
153
190
  bug_tracker_uri: https://github.com/rails/rails/issues
154
- changelog_uri: https://github.com/rails/rails/blob/v6.0.6.1/activestorage/CHANGELOG.md
155
- documentation_uri: https://api.rubyonrails.org/v6.0.6.1/
191
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.7.6/activestorage/CHANGELOG.md
192
+ documentation_uri: https://api.rubyonrails.org/v6.1.7.6/
156
193
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
157
- source_code_uri: https://github.com/rails/rails/tree/v6.0.6.1/activestorage
194
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.7.6/activestorage
158
195
  rubygems_mfa_required: 'true'
159
196
  post_install_message:
160
197
  rdoc_options: []
@@ -171,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
208
  - !ruby/object:Gem::Version
172
209
  version: '0'
173
210
  requirements: []
174
- rubygems_version: 3.4.3
211
+ rubygems_version: 3.3.3
175
212
  signing_key:
176
213
  specification_version: 4
177
214
  summary: Local and cloud file storage framework.
@@ -1,9 +0,0 @@
1
- class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
2
- def up
3
- return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
4
-
5
- if table_exists?(:active_storage_blobs)
6
- add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
7
- end
8
- end
9
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "tmpdir"
4
- require "active_support/core_ext/string/filters"
5
-
6
- module ActiveStorage
7
- module Downloading
8
- def self.included(klass)
9
- ActiveSupport::Deprecation.warn <<~MESSAGE.squish, caller_locations(2)
10
- ActiveStorage::Downloading is deprecated and will be removed in Active Storage 6.1.
11
- Use ActiveStorage::Blob#open instead.
12
- MESSAGE
13
- end
14
-
15
- private
16
- # Opens a new tempfile in #tempdir and copies blob data into it. Yields the tempfile.
17
- def download_blob_to_tempfile #:doc:
18
- open_tempfile_for_blob do |file|
19
- download_blob_to file
20
- yield file
21
- end
22
- end
23
-
24
- def open_tempfile_for_blob
25
- tempfile = Tempfile.open([ "ActiveStorage", blob.filename.extension_with_delimiter ], tempdir)
26
-
27
- begin
28
- yield tempfile
29
- ensure
30
- tempfile.close!
31
- end
32
- end
33
-
34
- # Efficiently downloads blob data into the given file.
35
- def download_blob_to(file) #:doc:
36
- file.binmode
37
- blob.download { |chunk| file.write(chunk) }
38
- file.flush
39
- file.rewind
40
- end
41
-
42
- # Returns the directory in which tempfiles should be opened. Defaults to +Dir.tmpdir+.
43
- def tempdir #:doc:
44
- Dir.tmpdir
45
- end
46
- end
47
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mini_magick"
4
-
5
- module ActiveStorage
6
- module Transformers
7
- class MiniMagickTransformer < Transformer
8
- private
9
- def process(file, format:)
10
- image = MiniMagick::Image.new(file.path, file)
11
-
12
- transformations.each do |name, argument_or_subtransformations|
13
- image.mogrify do |command|
14
- if name.to_s == "combine_options"
15
- argument_or_subtransformations.each do |subtransformation_name, subtransformation_argument|
16
- pass_transform_argument(command, subtransformation_name, subtransformation_argument)
17
- end
18
- else
19
- pass_transform_argument(command, name, argument_or_subtransformations)
20
- end
21
- end
22
- end
23
-
24
- image.format(format) if format
25
-
26
- image.tempfile.tap(&:open)
27
- end
28
-
29
- def pass_transform_argument(command, method, argument)
30
- if argument == true
31
- command.public_send(method)
32
- elsif argument.present?
33
- command.public_send(method, argument)
34
- end
35
- end
36
- end
37
- end
38
- end