activestorage 7.0.6 → 7.1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +208 -226
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +6 -6
  5. data/app/assets/javascripts/activestorage.esm.js +11 -7
  6. data/app/assets/javascripts/activestorage.js +12 -6
  7. data/app/controllers/active_storage/blobs/proxy_controller.rb +1 -0
  8. data/app/controllers/active_storage/disk_controller.rb +4 -2
  9. data/app/controllers/active_storage/representations/proxy_controller.rb +2 -1
  10. data/app/controllers/concerns/active_storage/disable_session.rb +12 -0
  11. data/app/controllers/concerns/active_storage/file_server.rb +4 -1
  12. data/app/javascript/activestorage/blob_record.js +4 -1
  13. data/app/javascript/activestorage/direct_upload.js +3 -2
  14. data/app/javascript/activestorage/index.js +3 -1
  15. data/app/javascript/activestorage/ujs.js +3 -3
  16. data/app/jobs/active_storage/analyze_job.rb +1 -1
  17. data/app/jobs/active_storage/mirror_job.rb +1 -1
  18. data/app/jobs/active_storage/preview_image_job.rb +16 -0
  19. data/app/jobs/active_storage/purge_job.rb +1 -1
  20. data/app/jobs/active_storage/transform_job.rb +12 -0
  21. data/app/models/active_storage/attachment.rb +100 -15
  22. data/app/models/active_storage/blob/analyzable.rb +4 -3
  23. data/app/models/active_storage/blob/identifiable.rb +1 -0
  24. data/app/models/active_storage/blob/representable.rb +15 -3
  25. data/app/models/active_storage/blob/servable.rb +22 -0
  26. data/app/models/active_storage/blob.rb +31 -67
  27. data/app/models/active_storage/current.rb +0 -10
  28. data/app/models/active_storage/filename.rb +2 -0
  29. data/app/models/active_storage/named_variant.rb +21 -0
  30. data/app/models/active_storage/preview.rb +11 -4
  31. data/app/models/active_storage/variant.rb +10 -7
  32. data/app/models/active_storage/variant_record.rb +0 -2
  33. data/app/models/active_storage/variant_with_record.rb +21 -7
  34. data/app/models/active_storage/variation.rb +5 -3
  35. data/config/routes.rb +6 -4
  36. data/db/migrate/20170806125915_create_active_storage_tables.rb +1 -1
  37. data/lib/active_storage/analyzer/audio_analyzer.rb +16 -4
  38. data/lib/active_storage/analyzer/image_analyzer.rb +2 -0
  39. data/lib/active_storage/analyzer/video_analyzer.rb +3 -1
  40. data/lib/active_storage/analyzer.rb +2 -0
  41. data/lib/active_storage/attached/changes/create_many.rb +8 -3
  42. data/lib/active_storage/attached/changes/create_one.rb +45 -3
  43. data/lib/active_storage/attached/many.rb +5 -4
  44. data/lib/active_storage/attached/model.rb +80 -47
  45. data/lib/active_storage/attached/one.rb +5 -4
  46. data/lib/active_storage/attached.rb +2 -0
  47. data/lib/active_storage/deprecator.rb +7 -0
  48. data/lib/active_storage/engine.rb +11 -7
  49. data/lib/active_storage/fixture_set.rb +7 -1
  50. data/lib/active_storage/gem_version.rb +4 -4
  51. data/lib/active_storage/log_subscriber.rb +12 -0
  52. data/lib/active_storage/previewer.rb +8 -1
  53. data/lib/active_storage/reflection.rb +3 -3
  54. data/lib/active_storage/service/azure_storage_service.rb +2 -0
  55. data/lib/active_storage/service/disk_service.rb +2 -0
  56. data/lib/active_storage/service/gcs_service.rb +11 -20
  57. data/lib/active_storage/service/mirror_service.rb +10 -5
  58. data/lib/active_storage/service/s3_service.rb +2 -0
  59. data/lib/active_storage/service.rb +4 -2
  60. data/lib/active_storage/transformers/transformer.rb +2 -0
  61. data/lib/active_storage/version.rb +1 -1
  62. data/lib/active_storage.rb +19 -6
  63. metadata +20 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e1f03d34e4a15967b60c668e71894d42539fbf0fb02279e66c78b7fcdec1a32
4
- data.tar.gz: '080f412cdd6a8b2f71492b9b3f37a0b0c5ca684ab1b33f1e3042e4493a4fe3ae'
3
+ metadata.gz: 3e2fdc79c02f31ae87546d38d509d76e6745aa1613b53d3242036eaede2df98c
4
+ data.tar.gz: db43b46d975c7794b7dcc9948899b4c1cdd1f4d8002266e6bd9078fee560732f
5
5
  SHA512:
6
- metadata.gz: 90ceefcc3bed54ef29409ae64ea023eed36190ad986633b990614541945d8a045ba6e724451f5376fa3018d612ab3f0e205a8991aeb9852b258bef1df426db58
7
- data.tar.gz: 759f5bf6704a4a94abec338564447b6cc39d7a9e8018f154c31f7c01a56a59c86d44f99a146c2dae570eb000dcc0fe35cdcdd93ff27faa540934dae3c4ee9438
6
+ metadata.gz: 93ff6753974b1f2ce12bb81c867c5ae0432de55dcb90db8e768c9911152651f48594c312f321c5e8e5971be826556f8338e20b80a07fd736a54884b0af2f790c
7
+ data.tar.gz: fa516053c9d81e0c6ac8003e5aeaee1be1e62c16e32c9ae0ec2fbcae41ebb255c3e49e780c5b1b58ca57049ee3ed421ecc08eb822d42ba58fb30e86d6c1ebdaf
data/CHANGELOG.md CHANGED
@@ -1,384 +1,366 @@
1
- ## Rails 7.0.6 (June 29, 2023) ##
1
+ ## Rails 7.1.5.2 (August 13, 2025) ##
2
2
 
3
- * Fix retrieving rotation value from FFmpeg on version 5.0+.
3
+ Remove dangerous transformations
4
4
 
5
- In FFmpeg version 5.0+ the rotation value has been removed from tags.
6
- Instead the value can be found in side_data_list. Along with
7
- this update it's possible to have values of -90, -270 to denote the video
8
- has been rotated.
9
-
10
- *Haroon Ahmed*
5
+ [CVE-2025-24293]
11
6
 
7
+ *Zack Deveau*
12
8
 
13
- ## Rails 7.0.5.1 (June 26, 2023) ##
9
+ ## Rails 7.1.5.1 (December 10, 2024) ##
14
10
 
15
11
  * No changes.
16
12
 
17
13
 
18
- ## Rails 7.0.5 (May 24, 2023) ##
14
+ ## Rails 7.1.5 (October 30, 2024) ##
19
15
 
20
16
  * No changes.
21
17
 
22
18
 
23
- ## Rails 7.0.4.3 (March 13, 2023) ##
19
+ ## Rails 7.1.4.2 (October 23, 2024) ##
24
20
 
25
21
  * No changes.
26
22
 
27
23
 
28
- ## Rails 7.0.4.2 (January 24, 2023) ##
24
+ ## Rails 7.1.4.1 (October 15, 2024) ##
29
25
 
30
26
  * No changes.
31
27
 
32
28
 
33
- ## Rails 7.0.4.1 (January 17, 2023) ##
34
-
35
- * No changes.
29
+ ## Rails 7.1.4 (August 22, 2024) ##
36
30
 
31
+ * Fixes race condition for multiple preprocessed video variants.
37
32
 
38
- ## Rails 7.0.4 (September 09, 2022) ##
33
+ *Justin Searls*
39
34
 
40
- * Fixes proxy downloads of files over 5MiB
41
35
 
42
- Previously, trying to view and/or download files larger than 5mb stored in
43
- services like S3 via proxy mode could return corrupted files at around
44
- 5.2mb or cause random halts in the download. Now,
45
- `ActiveStorage::Blobs::ProxyController` correctly handles streaming these
46
- larger files from the service to the client without any issues.
36
+ ## Rails 7.1.3.4 (June 04, 2024) ##
47
37
 
48
- Fixes #44679
38
+ * No changes.
49
39
 
50
- *Felipe Raul*
51
40
 
52
- ## Rails 7.0.3.1 (July 12, 2022) ##
41
+ ## Rails 7.1.3.3 (May 16, 2024) ##
53
42
 
54
43
  * No changes.
55
44
 
56
45
 
57
- ## Rails 7.0.3 (May 09, 2022) ##
46
+ ## Rails 7.1.3.2 (February 21, 2024) ##
58
47
 
59
- * Don't stream responses in redirect mode
60
-
61
- Previously, both redirect mode and proxy mode streamed their
62
- responses which caused a new thread to be created, and could end
63
- up leaking connections in the connection pool. But since redirect
64
- mode doesn't actually send any data, it doesn't need to be
65
- streamed.
48
+ * No changes.
66
49
 
67
- *Luke Lau*
68
50
 
69
- ## Rails 7.0.2.4 (April 26, 2022) ##
51
+ ## Rails 7.1.3.1 (February 21, 2024) ##
70
52
 
71
53
  * No changes.
72
54
 
73
55
 
74
- ## Rails 7.0.2.3 (March 08, 2022) ##
75
-
76
- * Added image transformation validation via configurable allow-list.
77
-
78
- Variant now offers a configurable allow-list for
79
- transformation methods in addition to a configurable deny-list for arguments.
56
+ ## Rails 7.1.3 (January 16, 2024) ##
80
57
 
81
- [CVE-2022-21831]
58
+ * Fix N+1 query when fetching preview images for non-image assets.
82
59
 
60
+ *Aaron Patterson & Justin Searls*
83
61
 
84
- ## Rails 7.0.2.2 (February 11, 2022) ##
62
+ * Fix all Active Storage database related models to respect
63
+ `ActiveRecord::Base.table_name_prefix` configuration.
85
64
 
86
- * No changes.
65
+ *Chedli Bourguiba*
87
66
 
88
- ## Rails 7.0.2.1 (February 11, 2022) ##
67
+ * Fix `ActiveStorage::Representations::ProxyController` not returning the proper
68
+ preview image variant for previewable files.
89
69
 
90
- * No changes.
70
+ *Chedli Bourguiba*
91
71
 
72
+ * Fix `ActiveStorage::Representations::ProxyController` to proxy untracked
73
+ variants.
92
74
 
93
- ## Rails 7.0.2 (February 08, 2022) ##
75
+ *Chedli Bourguiba*
94
76
 
95
- * Revert the ability to pass `service_name` param to `DirectUploadsController` which was introduced
96
- in 7.0.0.
77
+ * Fix direct upload forms when submit button contains nested elements.
97
78
 
98
- That change caused a lot of problems to upgrade Rails applications so we decided to remove it
99
- while in work in a more backwards compatible implementation.
79
+ *Marc Köhlbrugge*
100
80
 
101
- *Gannon McGibbon*
81
+ * When using the `preprocessed: true` option, avoid enqueuing transform jobs
82
+ for blobs that are not representable.
102
83
 
103
- * Allow applications to opt out of precompiling Active Storage JavaScript assets.
84
+ *Chedli Bourguiba*
104
85
 
105
- *jlestavel*
86
+ * Process preview image variant when calling `ActiveStorage::Preview#processed`.
87
+ For example, `attached_pdf.preview(:thumb).processed` will now immediately
88
+ generate the full-sized preview image and the `:thumb` variant of it.
89
+ Previously, the `:thumb` variant would not be generated until a further call
90
+ to e.g. `processed.url`.
106
91
 
92
+ *Chedli Bourguiba* and *Jonathan Hefner*
107
93
 
108
- ## Rails 7.0.1 (January 06, 2022) ##
94
+ * Prevent `ActiveRecord::StrictLoadingViolationError` when strict loading is
95
+ enabled and the variant of an Active Storage preview has already been
96
+ processed (for example, by calling `ActiveStorage::Preview#url`).
109
97
 
110
- * No changes.
98
+ *Jonathan Hefner*
111
99
 
100
+ * Fix `preprocessed: true` option for named variants of previewable files.
112
101
 
113
- ## Rails 7.0.0 (December 15, 2021) ##
102
+ *Nico Wenterodt*
114
103
 
115
- * Support transforming empty-ish `has_many_attached` value into `[]` (e.g. `[""]`).
116
104
 
117
- ```ruby
118
- @user.highlights = [""]
119
- @user.highlights # => []
120
- ```
105
+ ## Rails 7.1.2 (November 10, 2023) ##
121
106
 
122
- *Sean Doyle*
107
+ * No changes.
123
108
 
124
109
 
125
- ## Rails 7.0.0.rc3 (December 14, 2021) ##
110
+ ## Rails 7.1.1 (October 11, 2023) ##
126
111
 
127
112
  * No changes.
128
113
 
129
114
 
130
- ## Rails 7.0.0.rc2 (December 14, 2021) ##
115
+ ## Rails 7.1.0 (October 05, 2023) ##
131
116
 
132
117
  * No changes.
133
118
 
134
- ## Rails 7.0.0.rc1 (December 06, 2021) ##
135
119
 
136
- * `Add ActiveStorage::Blob.compose` to concatenate multiple blobs.
120
+ ## Rails 7.1.0.rc2 (October 01, 2023) ##
137
121
 
138
- *Gannon McGibbon*
122
+ * No changes.
139
123
 
140
- * Setting custom metadata on blobs are now persisted to remote storage.
141
124
 
142
- *joshuamsager*
125
+ ## Rails 7.1.0.rc1 (September 27, 2023) ##
143
126
 
144
- * Support direct uploads to multiple services.
127
+ * Add `expires_at` option to `ActiveStorage::Blob#signed_id`.
145
128
 
146
- *Dmitry Tsepelev*
129
+ ```ruby
130
+ rails_blob_path(user.avatar, disposition: "attachment", expires_at: 30.minutes.from_now)
131
+ <%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_at: 30.minutes.from_now) %>
132
+ ```
147
133
 
148
- * Invalid default content types are deprecated
134
+ *Aki*
149
135
 
150
- Blobs created with content_type `image/jpg`, `image/pjpeg`, `image/bmp`, `text/javascript` will now produce
151
- a deprecation warning, since these are not valid content types.
136
+ * Allow attaching File and Pathname when assigning attributes, e.g.
152
137
 
153
- These content types will be removed from the defaults in Rails 7.1.
138
+ ```ruby
139
+ User.create!(avatar: File.open("image.jpg"))
140
+ User.create!(avatar: file_fixture("image.jpg"))
141
+ ```
154
142
 
155
- You can set `config.active_storage.silence_invalid_content_types_warning = true` to dismiss the warning.
143
+ *Dorian Marié*
156
144
 
157
- *Alex Ghiculescu*
158
145
 
159
- ## Rails 7.0.0.alpha2 (September 15, 2021) ##
146
+ ## Rails 7.1.0.beta1 (September 13, 2023) ##
160
147
 
161
- * No changes.
148
+ * Disables the session in `ActiveStorage::Blobs::ProxyController`
149
+ and `ActiveStorage::Representations::ProxyController`
150
+ in order to allow caching by default in some CDNs as CloudFlare
162
151
 
152
+ Fixes #44136
163
153
 
164
- ## Rails 7.0.0.alpha1 (September 15, 2021) ##
154
+ *Bruno Prieto*
165
155
 
166
- * Emit Active Support instrumentation events from Active Storage analyzers.
156
+ * Add `tags` to `ActiveStorage::Analyzer::AudioAnalyzer` output
167
157
 
168
- Fixes #42930
158
+ *Keaton Roux*
169
159
 
170
- *Shouichi Kamiya*
160
+ * Add an option to preprocess variants
171
161
 
172
- * Add support for byte range requests
162
+ ActiveStorage variants are processed on the fly when they are needed but
163
+ sometimes we're sure that they are accessed and want to processed them
164
+ upfront.
173
165
 
174
- *Tom Prats*
166
+ `preprocessed` option is added when declaring variants.
175
167
 
176
- * Attachments can be deleted after their association is no longer defined.
168
+ ```
169
+ class User < ApplicationRecord
170
+ has_one_attached :avatar do |attachable|
171
+ attachable.variant :thumb, resize_to_limit: [100, 100], preprocessed: true
172
+ end
173
+ end
174
+ ```
177
175
 
178
- Fixes #42514
176
+ *Shouichi Kamiya*
179
177
 
180
- *Don Sisco*
178
+ * Fix variants not included when eager loading multiple records containing a single attachment
181
179
 
182
- * Make `vips` the default variant processor for new apps.
180
+ When using the `with_attached_#{name}` scope for a `has_one_attached` relation,
181
+ attachment variants were not eagerly loaded.
183
182
 
184
- See the upgrade guide for instructions on converting from `mini_magick` to `vips`. `mini_magick` is
185
- not deprecated, existing apps can keep using it.
183
+ *Russell Porter*
186
184
 
187
- *Breno Gazzola*
185
+ * Allow an ActiveStorage attachment to be removed via a form post
188
186
 
189
- * Deprecate `ActiveStorage::Current.host` in favor of `ActiveStorage::Current.url_options` which accepts
190
- a host, protocol and port.
187
+ Attachments can already be removed by updating the attachment to be nil such as:
188
+ ```ruby
189
+ User.find(params[:id]).update!(avatar: nil)
190
+ ```
191
191
 
192
- *Santiago Bartesaghi*
192
+ However, a form cannot post a nil param, it can only post an empty string. But, posting an
193
+ empty string would result in an `ActiveSupport::MessageVerifier::InvalidSignature: mismatched digest`
194
+ error being raised, because it's being treated as a signed blob id.
193
195
 
194
- * Allow using [IAM](https://cloud.google.com/storage/docs/access-control/signed-urls) when signing URLs with GCS.
196
+ Now, nil and an empty string are treated as a delete, which allows attachments to be removed via:
197
+ ```ruby
198
+ User.find(params[:id]).update!(params.require(:user).permit(:avatar))
195
199
 
196
- ```yaml
197
- gcs:
198
- service: GCS
199
- ...
200
- iam: true
201
200
  ```
202
201
 
203
- *RRethy*
202
+ *Nate Matykiewicz*
204
203
 
205
- * OpenSSL constants are now used for Digest computations.
204
+ * Remove mini_mime usage in favour of marcel.
206
205
 
207
- *Dirkjan Bussink*
206
+ We have two libraries that are have similar usage. This change removes
207
+ dependency on mini_mime and makes use of similar methods from marcel.
208
208
 
209
- * Deprecate `config.active_storage.replace_on_assign_to_many`. Future versions of Rails
210
- will behave the same way as when the config is set to `true`.
209
+ *Vipul A M*
211
210
 
212
- *Santiago Bartesaghi*
213
-
214
- * Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
215
- and `service_url` in favor of `url`.
216
-
217
- *Santiago Bartesaghi*
211
+ * Allow destroying active storage variants
218
212
 
219
- * Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
213
+ ```ruby
214
+ User.first.avatar.variant(resize_to_limit: [100, 100]).destroy
215
+ ```
220
216
 
221
- *Anton Topchii*, *Andrew White*
217
+ *Shouichi Kamiya*, *Yuichiro NAKAGAWA*, *Ryohei UEDA*
222
218
 
223
- * Allow to detach an attachment when record is not persisted.
219
+ * Add `sample_rate` to `ActiveStorage::Analyzer::AudioAnalyzer` output
224
220
 
225
- *Jacopo Beschi*
221
+ *Matija Čupić*
226
222
 
227
- * Use libvips instead of ImageMagick to analyze images when `active_storage.variant_processor = vips`.
223
+ * Remove deprecated `purge` and `purge_later` methods from the attachments association.
228
224
 
229
- *Breno Gazzola*
225
+ *Rafael Mendonça França*
230
226
 
231
- * Add metadata value for presence of video channel in video blobs.
227
+ * Remove deprecated behavior when assigning to a collection of attachments.
232
228
 
233
- The `metadata` attribute of video blobs has a new boolean key named `video` that is set to
234
- `true` if the file has an video channel and `false` if it doesn't.
229
+ Instead of appending to the collection, the collection is now replaced.
235
230
 
236
- *Breno Gazzola*
231
+ *Rafael Mendonça França*
237
232
 
238
- * Deprecate usage of `purge` and `purge_later` from the association extension.
233
+ * Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods.
239
234
 
240
- *Jacopo Beschi*
235
+ *Rafael Mendonça França*
241
236
 
242
- * Passing extra parameters in `ActiveStorage::Blob#url` to S3 Client.
237
+ * Remove deprecated invalid default content types in Active Storage configurations.
243
238
 
244
- This allows calls of `ActiveStorage::Blob#url` to have more interaction with
245
- the S3 Presigner, enabling, amongst other options, custom S3 domain URL
246
- Generation.
239
+ *Rafael Mendonça França*
247
240
 
248
- ```ruby
249
- blob = ActiveStorage::Blob.last
241
+ * Add missing preview event to `ActiveStorage::LogSubscriber`
250
242
 
251
- blob.url # => https://<bucket-name>.s3.<region>.amazonaws.com/<key>
252
- blob.url(virtual_host: true) # => # => https://<bucket-name>/<key>
253
- ```
243
+ A `preview` event is being instrumented in `ActiveStorage::Previewer`.
244
+ However it was not added inside ActiveStorage's LogSubscriber class.
254
245
 
255
- *josegomezr*
246
+ This will allow to have logs for when a preview happens
247
+ in the same fashion as all other ActiveStorage events such as
248
+ `upload` and `download` inside `Rails.logger`.
256
249
 
257
- * Allow setting a `Cache-Control` on files uploaded to GCS.
250
+ *Chedli Bourguiba*
258
251
 
259
- ```yaml
260
- gcs:
261
- service: GCS
262
- ...
263
- cache_control: "public, max-age=3600"
264
- ```
252
+ * Fix retrieving rotation value from FFmpeg on version 5.0+.
265
253
 
266
- *maleblond*
254
+ In FFmpeg version 5.0+ the rotation value has been removed from tags.
255
+ Instead the value can be found in side_data_list. Along with
256
+ this update it's possible to have values of -90, -270 to denote the video
257
+ has been rotated.
267
258
 
268
- * The parameters sent to `ffmpeg` for generating a video preview image are now
269
- configurable under `config.active_storage.video_preview_arguments`.
259
+ *Haroon Ahmed*
270
260
 
271
- *Brendon Muir*
261
+ * Touch all corresponding model records after ActiveStorage::Blob is analyzed
272
262
 
273
- * The ActiveStorage video previewer will now use scene change detection to generate
274
- better preview images (rather than the previous default of using the first frame
275
- of the video). This change requires FFmpeg v3.4+.
263
+ This fixes a race condition where a record can be requested and have a cache entry built, before
264
+ the initial `analyze_later` completes, which will not be invalidated until something else
265
+ updates the record. This also invalidates cache entries when a blob is re-analyzed, which
266
+ is helpful if a bug is fixed in an analyzer or a new analyzer is added.
276
267
 
277
- *Jonathan Hefner*
268
+ *Nate Matykiewicz*
278
269
 
279
- * Add support for ActiveStorage expiring URLs.
270
+ * Add ability to use pre-defined variants when calling `preview` or
271
+ `representation` on an attachment.
280
272
 
281
273
  ```ruby
282
- rails_blob_path(user.avatar, disposition: "attachment", expires_in: 30.minutes)
274
+ class User < ActiveRecord::Base
275
+ has_one_attached :file do |attachable|
276
+ attachable.variant :thumb, resize_to_limit: [100, 100]
277
+ end
278
+ end
283
279
 
284
- <%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_in: 30.minutes) %>
280
+ <%= image_tag user.file.representation(:thumb) %>
285
281
  ```
286
282
 
287
- If you want to set default expiration time for ActiveStorage URLs throughout your application, set `config.active_storage.urls_expire_in`.
288
-
289
- *aki77*
290
-
291
- * Allow to purge an attachment when record is not persisted for `has_many_attached`.
292
-
293
- *Jacopo Beschi*
294
-
295
- * Add `with_all_variant_records` method to eager load all variant records on an attachment at once.
296
- `with_attached_image` scope now eager loads variant records if using variant tracking.
297
-
298
- *Alex Ghiculescu*
299
-
300
- * Add metadata value for presence of audio channel in video blobs.
283
+ *Richard Böhme*
301
284
 
302
- The `metadata` attribute of video blobs has a new boolean key named `audio` that is set to
303
- `true` if the file has an audio channel and `false` if it doesn't.
285
+ * Method `attach` always returns the attachments except when the record
286
+ is persisted, unchanged, and saving it fails, in which case it returns `nil`.
304
287
 
305
- *Breno Gazzola*
306
-
307
- * Adds analyzer for audio files.
308
-
309
- *Breno Gazzola*
310
-
311
- * Respect Active Record's primary_key_type in Active Storage migrations.
312
-
313
- *fatkodima*
288
+ *Santiago Bartesaghi*
314
289
 
315
- * Allow `expires_in` for ActiveStorage signed ids.
290
+ * Fixes multiple `attach` calls within transaction not uploading files correctly.
316
291
 
317
- *aki77*
292
+ In the following example, the code failed to upload all but the last file to the configured service.
293
+ ```ruby
294
+ ActiveRecord::Base.transaction do
295
+ user.attachments.attach({
296
+ content_type: "text/plain",
297
+ filename: "dummy.txt",
298
+ io: ::StringIO.new("dummy"),
299
+ })
300
+ user.attachments.attach({
301
+ content_type: "text/plain",
302
+ filename: "dummy2.txt",
303
+ io: ::StringIO.new("dummy2"),
304
+ })
305
+ end
318
306
 
319
- * Allow to purge an attachment when record is not persisted for `has_one_attached`.
307
+ assert_equal 2, user.attachments.count
308
+ assert user.attachments.first.service.exist?(user.attachments.first.key) # Fails
309
+ ```
320
310
 
321
- *Jacopo Beschi*
311
+ This was addressed by keeping track of the subchanges pending upload, and uploading them
312
+ once the transaction is committed.
322
313
 
323
- * Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
324
- to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
325
- `ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
326
- that already have load hooks.
314
+ Fixes #41661
327
315
 
328
- *Brendon Muir*
316
+ *Santiago Bartesaghi*, *Bruno Vezoli*, *Juan Roig*, *Abhay Nikam*
329
317
 
330
- * `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
318
+ * Raise an exception if `config.active_storage.service` is not set.
331
319
 
332
- *Alex Robbin*
320
+ If Active Storage is configured and `config.active_storage.service` is not
321
+ set in the respective environment's configuration file, then an exception
322
+ is raised with a meaningful message when attempting to use Active Storage.
333
323
 
334
- * Add `ActiveStorage::Streaming` module that can be included in a controller to get access to `#send_blob_stream`,
335
- which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
324
+ *Ghouse Mohamed*
336
325
 
337
- ```ruby
338
- class MyPublicBlobsController < ApplicationController
339
- include ActiveStorage::SetBlob, ActiveStorage::Streaming
326
+ * Fixes proxy downloads of files over 5mb
340
327
 
341
- def show
342
- http_cache_forever(public: true) do
343
- send_blob_stream @blob, disposition: params[:disposition]
344
- end
345
- end
346
- end
347
- ```
328
+ Previously, trying to view and/or download files larger than 5mb stored in
329
+ services like S3 via proxy mode could return corrupted files at around
330
+ 5.2mb or cause random halts in the download. Now,
331
+ `ActiveStorage::Blobs::ProxyController` correctly handles streaming these
332
+ larger files from the service to the client without any issues.
348
333
 
349
- *DHH*
334
+ Fixes #44679
350
335
 
351
- * Add ability to use pre-defined variants.
336
+ *Felipe Raul*
352
337
 
353
- ```ruby
354
- class User < ActiveRecord::Base
355
- has_one_attached :avatar do |attachable|
356
- attachable.variant :thumb, resize: "100x100"
357
- attachable.variant :medium, resize: "300x300", monochrome: true
358
- end
359
- end
338
+ * Saving attachment(s) to a record returns the blob/blobs object
360
339
 
361
- class Gallery < ActiveRecord::Base
362
- has_many_attached :photos do |attachable|
363
- attachable.variant :thumb, resize: "100x100"
364
- attachable.variant :medium, resize: "300x300", monochrome: true
365
- end
366
- end
340
+ Previously, saving attachments did not return the blob/blobs that
341
+ were attached. Now, saving attachments to a record with `#attach`
342
+ method returns the blob or array of blobs that were attached to
343
+ the record. If it fails to save the attachment(s), then it returns
344
+ `false`.
367
345
 
368
- <%= image_tag user.avatar.variant(:thumb) %>
369
- ```
346
+ *Ghouse Mohamed*
370
347
 
371
- *fatkodima*
348
+ * Don't stream responses in redirect mode
372
349
 
373
- * After setting `config.active_storage.resolve_model_to_route = :rails_storage_proxy`
374
- `rails_blob_path` and `rails_representation_path` will generate proxy URLs by default.
350
+ Previously, both redirect mode and proxy mode streamed their
351
+ responses which caused a new thread to be created, and could end
352
+ up leaking connections in the connection pool. But since redirect
353
+ mode doesn't actually send any data, it doesn't need to be
354
+ streamed.
375
355
 
376
- *Ali Ismayilov*
356
+ *Luke Lau*
377
357
 
378
- * Declare `ActiveStorage::FixtureSet` and `ActiveStorage::FixtureSet.blob` to
379
- improve fixture integration.
358
+ * Safe for direct upload on Libraries or Frameworks
380
359
 
381
- *Sean Doyle*
360
+ Enable the use of custom headers during direct uploads, which allows for
361
+ the inclusion of Authorization bearer tokens or other forms of authorization
362
+ tokens through headers.
382
363
 
364
+ *Radamés Roriz*
383
365
 
384
- Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activestorage/CHANGELOG.md) for previous changes.
366
+ Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activestorage/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2022 David Heinemeier Hansson, Basecamp
1
+ Copyright (c) David Heinemeier Hansson, 37signals LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -6,11 +6,11 @@ Files can be uploaded from the server to the cloud or directly from the client t
6
6
 
7
7
  Image files can furthermore be transformed using on-demand variants for quality, aspect ratio, size, or any other [MiniMagick](https://github.com/minimagick/minimagick) or [Vips](https://www.rubydoc.info/gems/ruby-vips/Vips/Image) supported transformation.
8
8
 
9
- You can read more about Active Storage in the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) guide.
9
+ You can read more about Active Storage in the [Active Storage Overview](https://guides.rubyonrails.org/active_storage_overview.html) guide.
10
10
 
11
11
  ## Compared to other storage solutions
12
12
 
13
- A key difference to how Active Storage works compared to other attachment solutions in Rails is through the use of built-in [Blob](https://github.com/rails/rails/blob/main/activestorage/app/models/active_storage/blob.rb) and [Attachment](https://github.com/rails/rails/blob/main/activestorage/app/models/active_storage/attachment.rb) models (backed by Active Record). This means existing application models do not need to be modified with additional columns to associate with files. Active Storage uses polymorphic associations via the `Attachment` join model, which then connects to the actual `Blob`.
13
+ A key difference to how Active Storage works compared to other attachment solutions in \Rails is through the use of built-in [Blob](https://github.com/rails/rails/blob/main/activestorage/app/models/active_storage/blob.rb) and [Attachment](https://github.com/rails/rails/blob/main/activestorage/app/models/active_storage/attachment.rb) models (backed by Active Record). This means existing application models do not need to be modified with additional columns to associate with files. Active Storage uses polymorphic associations via the `Attachment` join model, which then connects to the actual `Blob`.
14
14
 
15
15
  `Blob` models store attachment metadata (filename, content-type, etc.), and their identifier key in the storage service. Blob models do not store the actual binary data. They are intended to be immutable in spirit. One file, one blob. You can associate the same blob with multiple application models as well. And if you want to do transformations of a given `Blob`, the idea is that you'll simply create a new one, rather than attempt to mutate the existing one (though of course you can delete the previous version later if you don't need it).
16
16
 
@@ -144,11 +144,11 @@ Active Storage, with its included JavaScript library, supports uploading directl
144
144
 
145
145
  1. Include the Active Storage JavaScript in your application's JavaScript bundle or reference it directly.
146
146
 
147
- Requiring directly without bundling through the asset pipeline in the application html with autostart:
148
- ```html
147
+ Requiring directly without bundling through the asset pipeline in the application HTML with autostart:
148
+ ```erb
149
149
  <%= javascript_include_tag "activestorage" %>
150
150
  ```
151
- Requiring via importmap-rails without bundling through the asset pipeline in the application html without autostart as ESM:
151
+ Requiring via importmap-rails without bundling through the asset pipeline in the application HTML without autostart as ESM:
152
152
  ```ruby
153
153
  # config/importmap.rb
154
154
  pin "@rails/activestorage", to: "activestorage.esm.js"
@@ -170,7 +170,7 @@ Active Storage, with its included JavaScript library, supports uploading directl
170
170
  ```
171
171
  2. Annotate file inputs with the direct upload URL.
172
172
 
173
- ```ruby
173
+ ```erb
174
174
  <%= form.file_field :attachments, multiple: true, direct_upload: true %>
175
175
  ```
176
176
  3. That's it! Uploads begin upon form submission.