activestorage 7.0.8 → 7.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +188 -271
- data/MIT-LICENSE +1 -1
- data/README.md +6 -6
- data/app/assets/javascripts/activestorage.esm.js +11 -7
- data/app/assets/javascripts/activestorage.js +12 -6
- data/app/controllers/active_storage/blobs/proxy_controller.rb +1 -0
- data/app/controllers/active_storage/disk_controller.rb +4 -2
- data/app/controllers/active_storage/representations/proxy_controller.rb +2 -1
- data/app/controllers/concerns/active_storage/disable_session.rb +12 -0
- data/app/controllers/concerns/active_storage/file_server.rb +4 -1
- data/app/javascript/activestorage/blob_record.js +4 -1
- data/app/javascript/activestorage/direct_upload.js +3 -2
- data/app/javascript/activestorage/index.js +3 -1
- data/app/javascript/activestorage/ujs.js +3 -3
- data/app/jobs/active_storage/analyze_job.rb +1 -1
- data/app/jobs/active_storage/mirror_job.rb +1 -1
- data/app/jobs/active_storage/purge_job.rb +1 -1
- data/app/jobs/active_storage/transform_job.rb +12 -0
- data/app/models/active_storage/attachment.rb +90 -15
- data/app/models/active_storage/blob/analyzable.rb +4 -3
- data/app/models/active_storage/blob/identifiable.rb +1 -0
- data/app/models/active_storage/blob/representable.rb +7 -3
- data/app/models/active_storage/blob/servable.rb +22 -0
- data/app/models/active_storage/blob.rb +31 -67
- data/app/models/active_storage/current.rb +0 -10
- data/app/models/active_storage/filename.rb +2 -0
- data/app/models/active_storage/named_variant.rb +21 -0
- data/app/models/active_storage/preview.rb +11 -4
- data/app/models/active_storage/variant.rb +10 -7
- data/app/models/active_storage/variant_record.rb +0 -2
- data/app/models/active_storage/variant_with_record.rb +21 -7
- data/app/models/active_storage/variation.rb +5 -3
- data/config/routes.rb +6 -4
- data/db/migrate/20170806125915_create_active_storage_tables.rb +1 -1
- data/lib/active_storage/analyzer/audio_analyzer.rb +16 -4
- data/lib/active_storage/analyzer/image_analyzer.rb +2 -0
- data/lib/active_storage/analyzer/video_analyzer.rb +3 -1
- data/lib/active_storage/analyzer.rb +2 -0
- data/lib/active_storage/attached/changes/create_many.rb +8 -3
- data/lib/active_storage/attached/changes/create_one.rb +45 -3
- data/lib/active_storage/attached/many.rb +5 -4
- data/lib/active_storage/attached/model.rb +72 -43
- data/lib/active_storage/attached/one.rb +5 -4
- data/lib/active_storage/attached.rb +2 -0
- data/lib/active_storage/deprecator.rb +7 -0
- data/lib/active_storage/engine.rb +11 -7
- data/lib/active_storage/fixture_set.rb +7 -1
- data/lib/active_storage/gem_version.rb +4 -4
- data/lib/active_storage/log_subscriber.rb +12 -0
- data/lib/active_storage/previewer.rb +8 -1
- data/lib/active_storage/reflection.rb +3 -3
- data/lib/active_storage/service/azure_storage_service.rb +2 -0
- data/lib/active_storage/service/disk_service.rb +2 -0
- data/lib/active_storage/service/gcs_service.rb +11 -20
- data/lib/active_storage/service/mirror_service.rb +10 -5
- data/lib/active_storage/service/s3_service.rb +2 -0
- data/lib/active_storage/service.rb +4 -2
- data/lib/active_storage/transformers/transformer.rb +2 -0
- data/lib/active_storage/version.rb +1 -1
- data/lib/active_storage.rb +19 -3
- metadata +19 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c89b7d956e16b4ca848737433bae254a2984dc68ca27524074002faedf85075b
|
4
|
+
data.tar.gz: f91ba06642aad7480bf12848d90ba6d777231bbb7ce62e80e432e5d6e2471b35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2a037df3fd0e4a73f5a2482b7baccb91a4c960f742b463ffe6b1c711db61f465668ed4d6ffd817035e8731973b2a95aa4ddbc786850521f262cb9ce8d30b6c
|
7
|
+
data.tar.gz: e4a0004214d00be2aadd62cdc79d538ae94982978a1356f8e7ddaf109e502bc52a25571120524663071c02f200a6537bd74c48dfe5447deccfa47c61360be0bf
|
data/CHANGELOG.md
CHANGED
@@ -1,404 +1,321 @@
|
|
1
|
-
## Rails 7.
|
1
|
+
## Rails 7.1.3.2 (February 21, 2024) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails 7.
|
6
|
+
## Rails 7.1.3.1 (February 21, 2024) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails 7.
|
11
|
+
## Rails 7.1.3 (January 16, 2024) ##
|
12
12
|
|
13
|
-
*
|
13
|
+
* Fix N+1 query when fetching preview images for non-image assets.
|
14
14
|
|
15
|
+
*Aaron Patterson & Justin Searls*
|
15
16
|
|
16
|
-
|
17
|
+
* Fix all Active Storage database related models to respect
|
18
|
+
`ActiveRecord::Base.table_name_prefix` configuration.
|
17
19
|
|
18
|
-
*
|
20
|
+
*Chedli Bourguiba*
|
19
21
|
|
22
|
+
* Fix `ActiveStorage::Representations::ProxyController` not returning the proper
|
23
|
+
preview image variant for previewable files.
|
20
24
|
|
21
|
-
|
25
|
+
*Chedli Bourguiba*
|
22
26
|
|
23
|
-
* Fix
|
27
|
+
* Fix `ActiveStorage::Representations::ProxyController` to proxy untracked
|
28
|
+
variants.
|
24
29
|
|
25
|
-
|
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.
|
30
|
+
*Chedli Bourguiba*
|
29
31
|
|
30
|
-
|
32
|
+
* Fix direct upload forms when submit button contains nested elements.
|
31
33
|
|
34
|
+
*Marc Köhlbrugge*
|
32
35
|
|
33
|
-
|
36
|
+
* When using the `preprocessed: true` option, avoid enqueuing transform jobs
|
37
|
+
for blobs that are not representable.
|
34
38
|
|
35
|
-
*
|
39
|
+
*Chedli Bourguiba*
|
36
40
|
|
41
|
+
* Process preview image variant when calling `ActiveStorage::Preview#processed`.
|
42
|
+
For example, `attached_pdf.preview(:thumb).processed` will now immediately
|
43
|
+
generate the full-sized preview image and the `:thumb` variant of it.
|
44
|
+
Previously, the `:thumb` variant would not be generated until a further call
|
45
|
+
to e.g. `processed.url`.
|
37
46
|
|
38
|
-
|
47
|
+
*Chedli Bourguiba* and *Jonathan Hefner*
|
39
48
|
|
40
|
-
*
|
49
|
+
* Prevent `ActiveRecord::StrictLoadingViolationError` when strict loading is
|
50
|
+
enabled and the variant of an Active Storage preview has already been
|
51
|
+
processed (for example, by calling `ActiveStorage::Preview#url`).
|
41
52
|
|
53
|
+
*Jonathan Hefner*
|
42
54
|
|
43
|
-
|
55
|
+
* Fix `preprocessed: true` option for named variants of previewable files.
|
44
56
|
|
45
|
-
*
|
57
|
+
*Nico Wenterodt*
|
46
58
|
|
47
59
|
|
48
|
-
## Rails 7.
|
60
|
+
## Rails 7.1.2 (November 10, 2023) ##
|
49
61
|
|
50
62
|
* No changes.
|
51
63
|
|
52
64
|
|
53
|
-
## Rails 7.
|
65
|
+
## Rails 7.1.1 (October 11, 2023) ##
|
54
66
|
|
55
67
|
* No changes.
|
56
68
|
|
57
69
|
|
58
|
-
## Rails 7.0
|
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) ##
|
70
|
+
## Rails 7.1.0 (October 05, 2023) ##
|
73
71
|
|
74
72
|
* No changes.
|
75
73
|
|
76
74
|
|
77
|
-
## Rails 7.0.
|
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) ##
|
75
|
+
## Rails 7.1.0.rc2 (October 01, 2023) ##
|
90
76
|
|
91
77
|
* No changes.
|
92
78
|
|
93
79
|
|
94
|
-
## Rails 7.0.
|
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.
|
80
|
+
## Rails 7.1.0.rc1 (September 27, 2023) ##
|
100
81
|
|
101
|
-
|
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. `[""]`).
|
82
|
+
* Add `expires_at` option to `ActiveStorage::Blob#signed_id`.
|
136
83
|
|
137
84
|
```ruby
|
138
|
-
|
139
|
-
|
85
|
+
rails_blob_path(user.avatar, disposition: "attachment", expires_at: 30.minutes.from_now)
|
86
|
+
<%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_at: 30.minutes.from_now) %>
|
140
87
|
```
|
141
88
|
|
142
|
-
*
|
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) ##
|
89
|
+
*Aki*
|
151
90
|
|
152
|
-
*
|
153
|
-
|
154
|
-
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
155
|
-
|
156
|
-
* `Add ActiveStorage::Blob.compose` to concatenate multiple blobs.
|
157
|
-
|
158
|
-
*Gannon McGibbon*
|
159
|
-
|
160
|
-
* Setting custom metadata on blobs are now persisted to remote storage.
|
91
|
+
* Allow attaching File and Pathname when assigning attributes, e.g.
|
161
92
|
|
162
|
-
|
163
|
-
|
164
|
-
|
93
|
+
```ruby
|
94
|
+
User.create!(avatar: File.open("image.jpg"))
|
95
|
+
User.create!(avatar: file_fixture("image.jpg"))
|
96
|
+
```
|
165
97
|
|
166
|
-
*
|
98
|
+
*Dorian Marié*
|
167
99
|
|
168
|
-
* Invalid default content types are deprecated
|
169
100
|
|
170
|
-
|
171
|
-
a deprecation warning, since these are not valid content types.
|
101
|
+
## Rails 7.1.0.beta1 (September 13, 2023) ##
|
172
102
|
|
173
|
-
|
103
|
+
* Disables the session in `ActiveStorage::Blobs::ProxyController`
|
104
|
+
and `ActiveStorage::Representations::ProxyController`
|
105
|
+
in order to allow caching by default in some CDNs as CloudFlare
|
174
106
|
|
175
|
-
|
107
|
+
Fixes #44136
|
176
108
|
|
177
|
-
*
|
109
|
+
*Bruno Prieto*
|
178
110
|
|
179
|
-
|
111
|
+
* Add `tags` to `ActiveStorage::Analyzer::AudioAnalyzer` output
|
180
112
|
|
181
|
-
*
|
113
|
+
*Keaton Roux*
|
182
114
|
|
115
|
+
* Add an option to preprocess variants
|
183
116
|
|
184
|
-
|
117
|
+
ActiveStorage variants are processed on the fly when they are needed but
|
118
|
+
sometimes we're sure that they are accessed and want to processed them
|
119
|
+
upfront.
|
185
120
|
|
186
|
-
|
121
|
+
`preprocessed` option is added when declaring variants.
|
187
122
|
|
188
|
-
|
123
|
+
```
|
124
|
+
class User < ApplicationRecord
|
125
|
+
has_one_attached :avatar do |attachable|
|
126
|
+
attachable.variant :thumb, resize_to_limit: [100, 100], preprocessed: true
|
127
|
+
end
|
128
|
+
end
|
129
|
+
```
|
189
130
|
|
190
131
|
*Shouichi Kamiya*
|
191
132
|
|
192
|
-
*
|
193
|
-
|
194
|
-
*Tom Prats*
|
195
|
-
|
196
|
-
* Attachments can be deleted after their association is no longer defined.
|
197
|
-
|
198
|
-
Fixes #42514
|
199
|
-
|
200
|
-
*Don Sisco*
|
133
|
+
* Fix variants not included when eager loading multiple records containing a single attachment
|
201
134
|
|
202
|
-
|
135
|
+
When using the `with_attached_#{name}` scope for a `has_one_attached` relation,
|
136
|
+
attachment variants were not eagerly loaded.
|
203
137
|
|
204
|
-
|
205
|
-
not deprecated, existing apps can keep using it.
|
138
|
+
*Russell Porter*
|
206
139
|
|
207
|
-
|
140
|
+
* Allow an ActiveStorage attachment to be removed via a form post
|
208
141
|
|
209
|
-
|
210
|
-
|
142
|
+
Attachments can already be removed by updating the attachment to be nil such as:
|
143
|
+
```ruby
|
144
|
+
User.find(params[:id]).update!(avatar: nil)
|
145
|
+
```
|
211
146
|
|
212
|
-
|
147
|
+
However, a form cannot post a nil param, it can only post an empty string. But, posting an
|
148
|
+
empty string would result in an `ActiveSupport::MessageVerifier::InvalidSignature: mismatched digest`
|
149
|
+
error being raised, because it's being treated as a signed blob id.
|
213
150
|
|
214
|
-
|
151
|
+
Now, nil and an empty string are treated as a delete, which allows attachments to be removed via:
|
152
|
+
```ruby
|
153
|
+
User.find(params[:id]).update!(params.require(:user).permit(:avatar))
|
215
154
|
|
216
|
-
```yaml
|
217
|
-
gcs:
|
218
|
-
service: GCS
|
219
|
-
...
|
220
|
-
iam: true
|
221
155
|
```
|
222
156
|
|
223
|
-
*
|
157
|
+
*Nate Matykiewicz*
|
224
158
|
|
225
|
-
*
|
159
|
+
* Remove mini_mime usage in favour of marcel.
|
226
160
|
|
227
|
-
|
161
|
+
We have two libraries that are have similar usage. This change removes
|
162
|
+
dependency on mini_mime and makes use of similar methods from marcel.
|
228
163
|
|
229
|
-
*
|
230
|
-
will behave the same way as when the config is set to `true`.
|
164
|
+
*Vipul A M*
|
231
165
|
|
232
|
-
|
166
|
+
* Allow destroying active storage variants
|
233
167
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
*Santiago Bartesaghi*
|
238
|
-
|
239
|
-
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
|
168
|
+
```ruby
|
169
|
+
User.first.avatar.variant(resize_to_limit: [100, 100]).destroy
|
170
|
+
```
|
240
171
|
|
241
|
-
*
|
172
|
+
*Shouichi Kamiya*, *Yuichiro NAKAGAWA*, *Ryohei UEDA*
|
242
173
|
|
243
|
-
*
|
174
|
+
* Add `sample_rate` to `ActiveStorage::Analyzer::AudioAnalyzer` output
|
244
175
|
|
245
|
-
*
|
176
|
+
*Matija Čupić*
|
246
177
|
|
247
|
-
*
|
178
|
+
* Remove deprecated `purge` and `purge_later` methods from the attachments association.
|
248
179
|
|
249
|
-
*
|
180
|
+
*Rafael Mendonça França*
|
250
181
|
|
251
|
-
*
|
182
|
+
* Remove deprecated behavior when assigning to a collection of attachments.
|
252
183
|
|
253
|
-
|
254
|
-
`true` if the file has an video channel and `false` if it doesn't.
|
184
|
+
Instead of appending to the collection, the collection is now replaced.
|
255
185
|
|
256
|
-
*
|
186
|
+
*Rafael Mendonça França*
|
257
187
|
|
258
|
-
*
|
188
|
+
* Remove deprecated `ActiveStorage::Current#host` and `ActiveStorage::Current#host=` methods.
|
259
189
|
|
260
|
-
*
|
190
|
+
*Rafael Mendonça França*
|
261
191
|
|
262
|
-
*
|
192
|
+
* Remove deprecated invalid default content types in Active Storage configurations.
|
263
193
|
|
264
|
-
|
265
|
-
the S3 Presigner, enabling, amongst other options, custom S3 domain URL
|
266
|
-
Generation.
|
194
|
+
*Rafael Mendonça França*
|
267
195
|
|
268
|
-
|
269
|
-
blob = ActiveStorage::Blob.last
|
196
|
+
* Add missing preview event to `ActiveStorage::LogSubscriber`
|
270
197
|
|
271
|
-
|
272
|
-
|
273
|
-
```
|
198
|
+
A `preview` event is being instrumented in `ActiveStorage::Previewer`.
|
199
|
+
However it was not added inside ActiveStorage's LogSubscriber class.
|
274
200
|
|
275
|
-
|
201
|
+
This will allow to have logs for when a preview happens
|
202
|
+
in the same fashion as all other ActiveStorage events such as
|
203
|
+
`upload` and `download` inside `Rails.logger`.
|
276
204
|
|
277
|
-
*
|
205
|
+
*Chedli Bourguiba*
|
278
206
|
|
279
|
-
|
280
|
-
gcs:
|
281
|
-
service: GCS
|
282
|
-
...
|
283
|
-
cache_control: "public, max-age=3600"
|
284
|
-
```
|
207
|
+
* Fix retrieving rotation value from FFmpeg on version 5.0+.
|
285
208
|
|
286
|
-
|
209
|
+
In FFmpeg version 5.0+ the rotation value has been removed from tags.
|
210
|
+
Instead the value can be found in side_data_list. Along with
|
211
|
+
this update it's possible to have values of -90, -270 to denote the video
|
212
|
+
has been rotated.
|
287
213
|
|
288
|
-
*
|
289
|
-
configurable under `config.active_storage.video_preview_arguments`.
|
214
|
+
*Haroon Ahmed*
|
290
215
|
|
291
|
-
|
216
|
+
* Touch all corresponding model records after ActiveStorage::Blob is analyzed
|
292
217
|
|
293
|
-
|
294
|
-
|
295
|
-
|
218
|
+
This fixes a race condition where a record can be requested and have a cache entry built, before
|
219
|
+
the initial `analyze_later` completes, which will not be invalidated until something else
|
220
|
+
updates the record. This also invalidates cache entries when a blob is re-analyzed, which
|
221
|
+
is helpful if a bug is fixed in an analyzer or a new analyzer is added.
|
296
222
|
|
297
|
-
*
|
223
|
+
*Nate Matykiewicz*
|
298
224
|
|
299
|
-
* Add
|
225
|
+
* Add ability to use pre-defined variants when calling `preview` or
|
226
|
+
`representation` on an attachment.
|
300
227
|
|
301
228
|
```ruby
|
302
|
-
|
229
|
+
class User < ActiveRecord::Base
|
230
|
+
has_one_attached :file do |attachable|
|
231
|
+
attachable.variant :thumb, resize_to_limit: [100, 100]
|
232
|
+
end
|
233
|
+
end
|
303
234
|
|
304
|
-
<%= image_tag
|
235
|
+
<%= image_tag user.file.representation(:thumb) %>
|
305
236
|
```
|
306
237
|
|
307
|
-
|
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.
|
238
|
+
*Richard Böhme*
|
317
239
|
|
318
|
-
|
240
|
+
* Method `attach` always returns the attachments except when the record
|
241
|
+
is persisted, unchanged, and saving it fails, in which case it returns `nil`.
|
319
242
|
|
320
|
-
*
|
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*
|
326
|
-
|
327
|
-
* Adds analyzer for audio files.
|
328
|
-
|
329
|
-
*Breno Gazzola*
|
330
|
-
|
331
|
-
* Respect Active Record's primary_key_type in Active Storage migrations.
|
332
|
-
|
333
|
-
*fatkodima*
|
243
|
+
*Santiago Bartesaghi*
|
334
244
|
|
335
|
-
*
|
245
|
+
* Fixes multiple `attach` calls within transaction not uploading files correctly.
|
336
246
|
|
337
|
-
|
247
|
+
In the following example, the code failed to upload all but the last file to the configured service.
|
248
|
+
```ruby
|
249
|
+
ActiveRecord::Base.transaction do
|
250
|
+
user.attachments.attach({
|
251
|
+
content_type: "text/plain",
|
252
|
+
filename: "dummy.txt",
|
253
|
+
io: ::StringIO.new("dummy"),
|
254
|
+
})
|
255
|
+
user.attachments.attach({
|
256
|
+
content_type: "text/plain",
|
257
|
+
filename: "dummy2.txt",
|
258
|
+
io: ::StringIO.new("dummy2"),
|
259
|
+
})
|
260
|
+
end
|
338
261
|
|
339
|
-
|
262
|
+
assert_equal 2, user.attachments.count
|
263
|
+
assert user.attachments.first.service.exist?(user.attachments.first.key) # Fails
|
264
|
+
```
|
340
265
|
|
341
|
-
|
266
|
+
This was addressed by keeping track of the subchanges pending upload, and uploading them
|
267
|
+
once the transaction is committed.
|
342
268
|
|
343
|
-
|
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.
|
269
|
+
Fixes #41661
|
347
270
|
|
348
|
-
*
|
271
|
+
*Santiago Bartesaghi*, *Bruno Vezoli*, *Juan Roig*, *Abhay Nikam*
|
349
272
|
|
350
|
-
*
|
273
|
+
* Raise an exception if `config.active_storage.service` is not set.
|
351
274
|
|
352
|
-
|
275
|
+
If Active Storage is configured and `config.active_storage.service` is not
|
276
|
+
set in the respective environment's configuration file, then an exception
|
277
|
+
is raised with a meaningful message when attempting to use Active Storage.
|
353
278
|
|
354
|
-
*
|
355
|
-
which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
|
279
|
+
*Ghouse Mohamed*
|
356
280
|
|
357
|
-
|
358
|
-
class MyPublicBlobsController < ApplicationController
|
359
|
-
include ActiveStorage::SetBlob, ActiveStorage::Streaming
|
281
|
+
* Fixes proxy downloads of files over 5mb
|
360
282
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
end
|
367
|
-
```
|
283
|
+
Previously, trying to view and/or download files larger than 5mb stored in
|
284
|
+
services like S3 via proxy mode could return corrupted files at around
|
285
|
+
5.2mb or cause random halts in the download. Now,
|
286
|
+
`ActiveStorage::Blobs::ProxyController` correctly handles streaming these
|
287
|
+
larger files from the service to the client without any issues.
|
368
288
|
|
369
|
-
|
289
|
+
Fixes #44679
|
370
290
|
|
371
|
-
*
|
291
|
+
*Felipe Raul*
|
372
292
|
|
373
|
-
|
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
|
293
|
+
* Saving attachment(s) to a record returns the blob/blobs object
|
380
294
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
end
|
295
|
+
Previously, saving attachments did not return the blob/blobs that
|
296
|
+
were attached. Now, saving attachments to a record with `#attach`
|
297
|
+
method returns the blob or array of blobs that were attached to
|
298
|
+
the record. If it fails to save the attachment(s), then it returns
|
299
|
+
`false`.
|
387
300
|
|
388
|
-
|
389
|
-
```
|
301
|
+
*Ghouse Mohamed*
|
390
302
|
|
391
|
-
|
303
|
+
* Don't stream responses in redirect mode
|
392
304
|
|
393
|
-
|
394
|
-
|
305
|
+
Previously, both redirect mode and proxy mode streamed their
|
306
|
+
responses which caused a new thread to be created, and could end
|
307
|
+
up leaking connections in the connection pool. But since redirect
|
308
|
+
mode doesn't actually send any data, it doesn't need to be
|
309
|
+
streamed.
|
395
310
|
|
396
|
-
*
|
311
|
+
*Luke Lau*
|
397
312
|
|
398
|
-
*
|
399
|
-
improve fixture integration.
|
313
|
+
* Safe for direct upload on Libraries or Frameworks
|
400
314
|
|
401
|
-
|
315
|
+
Enable the use of custom headers during direct uploads, which allows for
|
316
|
+
the inclusion of Authorization bearer tokens or other forms of authorization
|
317
|
+
tokens through headers.
|
402
318
|
|
319
|
+
*Radamés Roriz*
|
403
320
|
|
404
|
-
Please check [
|
321
|
+
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activestorage/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
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://
|
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
|
148
|
-
```
|
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
|
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
|
-
```
|
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.
|