activestorage 7.0.8 → 7.1.1

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