activestorage 7.0.4 → 7.1.3.4

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