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