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