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