activestorage 6.0.5.1 → 6.1.7.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activestorage might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +228 -165
- data/MIT-LICENSE +1 -1
- data/README.md +35 -3
- data/app/controllers/active_storage/base_controller.rb +11 -0
- data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -0
- data/app/controllers/active_storage/{blobs_controller.rb → blobs/redirect_controller.rb} +2 -2
- data/app/controllers/active_storage/direct_uploads_controller.rb +1 -1
- data/app/controllers/active_storage/disk_controller.rb +8 -20
- data/app/controllers/active_storage/representations/base_controller.rb +14 -0
- data/app/controllers/active_storage/representations/proxy_controller.rb +13 -0
- data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +2 -4
- data/app/controllers/concerns/active_storage/file_server.rb +18 -0
- data/app/controllers/concerns/active_storage/set_blob.rb +1 -1
- data/app/controllers/concerns/active_storage/set_current.rb +2 -2
- data/app/controllers/concerns/active_storage/set_headers.rb +12 -0
- data/app/jobs/active_storage/mirror_job.rb +15 -0
- data/app/models/active_storage/attachment.rb +19 -11
- data/app/models/active_storage/blob/analyzable.rb +6 -2
- data/app/models/active_storage/blob/identifiable.rb +7 -6
- data/app/models/active_storage/blob/representable.rb +34 -4
- data/app/models/active_storage/blob.rb +122 -57
- data/app/models/active_storage/preview.rb +31 -10
- data/app/models/active_storage/record.rb +7 -0
- data/app/models/active_storage/variant.rb +31 -44
- data/app/models/active_storage/variant_record.rb +8 -0
- data/app/models/active_storage/variant_with_record.rb +54 -0
- data/app/models/active_storage/variation.rb +26 -21
- data/config/routes.rb +58 -8
- data/db/migrate/20170806125915_create_active_storage_tables.rb +30 -9
- data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +21 -0
- data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +26 -0
- data/lib/active_storage/analyzer/image_analyzer.rb +3 -0
- data/lib/active_storage/analyzer/null_analyzer.rb +4 -0
- data/lib/active_storage/analyzer/video_analyzer.rb +14 -3
- data/lib/active_storage/analyzer.rb +6 -0
- data/lib/active_storage/attached/changes/create_many.rb +1 -0
- data/lib/active_storage/attached/changes/create_one.rb +17 -4
- data/lib/active_storage/attached/many.rb +4 -3
- data/lib/active_storage/attached/model.rb +67 -14
- data/lib/active_storage/attached/one.rb +4 -3
- data/lib/active_storage/engine.rb +41 -43
- data/lib/active_storage/errors.rb +3 -0
- data/lib/active_storage/gem_version.rb +3 -3
- data/lib/active_storage/log_subscriber.rb +6 -0
- data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
- data/lib/active_storage/previewer/poppler_pdf_previewer.rb +2 -2
- data/lib/active_storage/previewer/video_previewer.rb +5 -3
- data/lib/active_storage/previewer.rb +13 -3
- data/lib/active_storage/service/azure_storage_service.rb +40 -35
- data/lib/active_storage/service/configurator.rb +3 -1
- data/lib/active_storage/service/disk_service.rb +36 -31
- data/lib/active_storage/service/gcs_service.rb +18 -16
- data/lib/active_storage/service/mirror_service.rb +31 -7
- data/lib/active_storage/service/registry.rb +32 -0
- data/lib/active_storage/service/s3_service.rb +51 -23
- data/lib/active_storage/service.rb +35 -7
- data/lib/active_storage/transformers/image_processing_transformer.rb +21 -308
- data/lib/active_storage/transformers/transformer.rb +0 -3
- data/lib/active_storage.rb +301 -7
- data/lib/tasks/activestorage.rake +5 -1
- metadata +53 -16
- data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +0 -9
- data/lib/active_storage/downloading.rb +0 -47
- data/lib/active_storage/transformers/mini_magick_transformer.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c65843f124d14c6b3e61b442d9f3a8bc9ae1057884a0f06c425e1e9d8c5dde5
|
4
|
+
data.tar.gz: 9623460f05657e13bfbfc20ea2691af6cd2c50d34aad0833563e478d63984455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7be337e274c5176309b6251ea8215ae47f71f3bdc8a380280a063643ad5d53d979358ea77c73bc77318959e911f48dc2f6517da06063ed4e5c8c11d655d05b7
|
7
|
+
data.tar.gz: 3407667800e04177470b27d4c94b3afb68ab3257999338657ce4f09e0a54250027c25e6e1f86b7f927686ef10c245c62a89c4b3a5fdbac080d08b99687e30ba4
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,54 @@
|
|
1
|
-
## Rails 6.
|
1
|
+
## Rails 6.1.7.4 (June 26, 2023) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails 6.
|
6
|
+
## Rails 6.1.7.3 (March 13, 2023) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails 6.
|
11
|
+
## Rails 6.1.7.2 (January 24, 2023) ##
|
12
12
|
|
13
13
|
* No changes.
|
14
14
|
|
15
15
|
|
16
|
-
## Rails 6.
|
16
|
+
## Rails 6.1.7.1 (January 17, 2023) ##
|
17
|
+
|
18
|
+
* No changes.
|
19
|
+
|
20
|
+
|
21
|
+
## Rails 6.1.7 (September 09, 2022) ##
|
22
|
+
|
23
|
+
* Respect Active Record's primary_key_type in Active Storage migrations. Backported from 7.0.
|
24
|
+
|
25
|
+
*fatkodima*
|
26
|
+
|
27
|
+
## Rails 6.1.6.1 (July 12, 2022) ##
|
28
|
+
|
29
|
+
* No changes.
|
30
|
+
|
31
|
+
|
32
|
+
## Rails 6.1.6 (May 09, 2022) ##
|
33
|
+
|
34
|
+
* No changes.
|
35
|
+
|
36
|
+
|
37
|
+
## Rails 6.1.5.1 (April 26, 2022) ##
|
38
|
+
|
39
|
+
* No changes.
|
40
|
+
|
41
|
+
|
42
|
+
## Rails 6.1.5 (March 09, 2022) ##
|
43
|
+
|
44
|
+
* Attachments can be deleted after their association is no longer defined.
|
45
|
+
|
46
|
+
Fixes #42514
|
47
|
+
|
48
|
+
*Don Sisco*
|
49
|
+
|
50
|
+
|
51
|
+
## Rails 6.1.4.7 (March 08, 2022) ##
|
17
52
|
|
18
53
|
* Added image transformation validation via configurable allow-list.
|
19
54
|
|
@@ -23,311 +58,339 @@
|
|
23
58
|
[CVE-2022-21831]
|
24
59
|
|
25
60
|
|
26
|
-
## Rails 6.
|
61
|
+
## Rails 6.1.4.6 (February 11, 2022) ##
|
27
62
|
|
28
63
|
* No changes.
|
29
64
|
|
30
65
|
|
31
|
-
## Rails 6.
|
66
|
+
## Rails 6.1.4.5 (February 11, 2022) ##
|
32
67
|
|
33
68
|
* No changes.
|
34
69
|
|
35
70
|
|
36
|
-
## Rails 6.
|
71
|
+
## Rails 6.1.4.4 (December 15, 2021) ##
|
37
72
|
|
38
73
|
* No changes.
|
39
74
|
|
40
75
|
|
41
|
-
## Rails 6.
|
76
|
+
## Rails 6.1.4.3 (December 14, 2021) ##
|
42
77
|
|
43
78
|
* No changes.
|
44
79
|
|
45
80
|
|
46
|
-
## Rails 6.
|
81
|
+
## Rails 6.1.4.2 (December 14, 2021) ##
|
47
82
|
|
48
83
|
* No changes.
|
49
84
|
|
50
85
|
|
51
|
-
## Rails 6.
|
86
|
+
## Rails 6.1.4.1 (August 19, 2021) ##
|
52
87
|
|
53
88
|
* No changes.
|
54
89
|
|
55
90
|
|
56
|
-
## Rails 6.
|
91
|
+
## Rails 6.1.4 (June 24, 2021) ##
|
57
92
|
|
58
|
-
* The
|
59
|
-
|
60
|
-
matches the behavior of the MuPDF previewer.
|
93
|
+
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
94
|
+
configurable under `config.active_storage.video_preview_arguments`.
|
61
95
|
|
62
|
-
*
|
96
|
+
*Brendon Muir*
|
63
97
|
|
98
|
+
* Fix Active Storage update task when running in an engine.
|
64
99
|
|
65
|
-
|
100
|
+
*Justin Malčić*
|
66
101
|
|
67
|
-
*
|
102
|
+
* Don't raise an error if the mime type is not recognized.
|
68
103
|
|
104
|
+
Fixes #41777.
|
69
105
|
|
70
|
-
|
106
|
+
*Alex Ghiculescu*
|
71
107
|
|
72
|
-
*
|
73
|
-
mime types data.
|
74
|
-
|
75
|
-
*George Claghorn*
|
108
|
+
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
76
109
|
|
110
|
+
*Alex Robbin*
|
77
111
|
|
78
|
-
|
112
|
+
* respond with 404 given invalid variation key when asking for representations.
|
79
113
|
|
80
|
-
*
|
114
|
+
*George Claghorn*
|
81
115
|
|
116
|
+
* `Blob` creation shouldn't crash if no service selected.
|
82
117
|
|
83
|
-
|
118
|
+
*Alex Ghiculescu*
|
84
119
|
|
85
|
-
* No changes.
|
86
120
|
|
87
|
-
|
88
|
-
## Rails 6.0.3.3 (September 09, 2020) ##
|
121
|
+
## Rails 6.1.3.2 (May 05, 2021) ##
|
89
122
|
|
90
123
|
* No changes.
|
91
124
|
|
92
125
|
|
93
|
-
## Rails 6.
|
126
|
+
## Rails 6.1.3.1 (March 26, 2021) ##
|
94
127
|
|
95
|
-
*
|
128
|
+
* Marcel is upgraded to version 1.0.0 to avoid a dependency on GPL-licensed
|
129
|
+
mime types data.
|
96
130
|
|
131
|
+
*George Claghorn*
|
97
132
|
|
98
|
-
## Rails 6.0.3.1 (May 18, 2020) ##
|
99
133
|
|
100
|
-
|
134
|
+
## Rails 6.1.3 (February 17, 2021) ##
|
135
|
+
|
136
|
+
* No changes.
|
101
137
|
|
102
138
|
|
103
|
-
## Rails 6.
|
139
|
+
## Rails 6.1.2.1 (February 10, 2021) ##
|
104
140
|
|
105
141
|
* No changes.
|
106
142
|
|
107
143
|
|
108
|
-
## Rails 6.
|
144
|
+
## Rails 6.1.2 (February 09, 2021) ##
|
109
145
|
|
110
146
|
* No changes.
|
111
147
|
|
112
148
|
|
113
|
-
## Rails 6.
|
149
|
+
## Rails 6.1.1 (January 07, 2021) ##
|
114
150
|
|
115
|
-
*
|
151
|
+
* Fix S3 multipart uploads when threshold is larger than file.
|
116
152
|
|
153
|
+
*Matt Muller*
|
117
154
|
|
118
|
-
## Rails 6.0.2 (December 13, 2019) ##
|
119
155
|
|
120
|
-
|
156
|
+
## Rails 6.1.0 (December 09, 2020) ##
|
121
157
|
|
158
|
+
* Change default queue name of the analysis (`:active_storage_analysis`) and
|
159
|
+
purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).
|
122
160
|
|
123
|
-
|
161
|
+
*Rafael Mendonça França*
|
124
162
|
|
125
|
-
* `
|
163
|
+
* Implement `strict_loading` on ActiveStorage associations.
|
126
164
|
|
127
|
-
*
|
165
|
+
*David Angulo*
|
128
166
|
|
129
|
-
*
|
130
|
-
This fixes that generated blob keys could silently collide, leading to
|
131
|
-
data loss.
|
167
|
+
* Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`.
|
132
168
|
|
133
|
-
*
|
169
|
+
*Rafael Mendonça França*
|
134
170
|
|
171
|
+
* Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer`.
|
135
172
|
|
136
|
-
|
173
|
+
*Rafael Mendonça França*
|
137
174
|
|
138
|
-
*
|
175
|
+
* Remove deprecated `config.active_storage.queue`.
|
139
176
|
|
177
|
+
*Rafael Mendonça França*
|
140
178
|
|
141
|
-
|
179
|
+
* Remove deprecated `ActiveStorage::Downloading`.
|
142
180
|
|
143
|
-
*
|
181
|
+
*Rafael Mendonça França*
|
144
182
|
|
183
|
+
* Add per-environment configuration support
|
145
184
|
|
146
|
-
|
185
|
+
*Pietro Moro*
|
147
186
|
|
148
|
-
*
|
187
|
+
* The Poppler PDF previewer renders a preview image using the original
|
188
|
+
document's crop box rather than its media box, hiding print margins. This
|
189
|
+
matches the behavior of the MuPDF previewer.
|
149
190
|
|
150
|
-
|
191
|
+
*Vincent Robert*
|
151
192
|
|
152
|
-
|
193
|
+
* Touch parent model when an attachment is purged.
|
153
194
|
|
154
|
-
*
|
195
|
+
*Víctor Pérez Rodríguez*
|
155
196
|
|
156
|
-
|
197
|
+
* Files can now be served by proxying them from the underlying storage service
|
198
|
+
instead of redirecting to a signed service URL. Use the
|
199
|
+
`rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
|
157
200
|
|
201
|
+
```erb
|
202
|
+
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
203
|
+
```
|
158
204
|
|
159
|
-
|
205
|
+
To proxy by default, set `config.active_storage.resolve_model_to_route`:
|
160
206
|
|
161
|
-
|
207
|
+
```ruby
|
208
|
+
# Proxy attached files instead.
|
209
|
+
config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
210
|
+
```
|
162
211
|
|
212
|
+
```erb
|
213
|
+
<%= image_tag @user.avatar %>
|
214
|
+
```
|
163
215
|
|
164
|
-
|
216
|
+
To redirect to a signed service URL when the default file serving strategy
|
217
|
+
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
165
218
|
|
166
|
-
|
219
|
+
```erb
|
220
|
+
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
221
|
+
```
|
167
222
|
|
223
|
+
*Jonathan Fleckenstein*
|
168
224
|
|
169
|
-
|
225
|
+
* Add `config.active_storage.web_image_content_types` to allow applications
|
226
|
+
to add content types (like `image/webp`) in which variants can be processed,
|
227
|
+
instead of letting those images be converted to the fallback PNG format.
|
170
228
|
|
171
|
-
*
|
172
|
-
[`activestorage`](https://www.npmjs.com/package/activestorage) to
|
173
|
-
[`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
|
229
|
+
*Jeroen van Haperen*
|
174
230
|
|
175
|
-
|
231
|
+
* Add support for creating variants of `WebP` images out of the box.
|
176
232
|
|
177
|
-
*
|
178
|
-
queues analysis and purge jobs should use, respectively:
|
233
|
+
*Dino Maric*
|
179
234
|
|
180
|
-
|
181
|
-
* `config.active_storage.queues.purge`
|
235
|
+
* Only enqueue analysis jobs for blobs with non-null analyzer classes.
|
182
236
|
|
183
|
-
|
184
|
-
set, but it is deprecated and will be removed in Rails 6.1.
|
237
|
+
*Gannon McGibbon*
|
185
238
|
|
186
|
-
|
239
|
+
* Previews are created on the same service as the original blob.
|
187
240
|
|
188
|
-
*
|
241
|
+
*Peter Zhu*
|
189
242
|
|
190
|
-
|
243
|
+
* Remove unused `disposition` and `content_type` query parameters for `DiskService`.
|
191
244
|
|
192
|
-
*
|
193
|
-
collisions and undefined behavior with case-insensitive filesystems and
|
194
|
-
database indices.
|
245
|
+
*Peter Zhu*
|
195
246
|
|
196
|
-
|
247
|
+
* Use `DiskController` for both public and private files.
|
197
248
|
|
198
|
-
|
199
|
-
|
249
|
+
`DiskController` is able to handle multiple services by adding a
|
250
|
+
`service_name` field in the generated URL in `DiskService`.
|
200
251
|
|
201
|
-
*
|
252
|
+
*Peter Zhu*
|
202
253
|
|
203
|
-
*
|
254
|
+
* Variants are tracked in the database to avoid existence checks in the storage service.
|
204
255
|
|
205
|
-
*
|
256
|
+
*George Claghorn*
|
206
257
|
|
207
|
-
*
|
258
|
+
* Deprecate `service_url` methods in favour of `url`.
|
208
259
|
|
209
|
-
|
260
|
+
Deprecate `Variant#service_url` and `Preview#service_url` to instead use
|
261
|
+
`#url` method to be consistent with `Blob`.
|
210
262
|
|
211
|
-
*
|
263
|
+
*Peter Zhu*
|
212
264
|
|
213
|
-
|
265
|
+
* Permanent URLs for public storage blobs.
|
214
266
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
exception class.
|
267
|
+
Services can be configured in `config/storage.yml` with a new key
|
268
|
+
`public: true | false` to indicate whether a service holds public
|
269
|
+
blobs or private blobs. Public services will always return a permanent URL.
|
219
270
|
|
220
|
-
|
271
|
+
Deprecates `Blob#service_url` in favor of `Blob#url`.
|
221
272
|
|
222
|
-
*
|
223
|
-
the requested file is missing from the disk service. It previously raised
|
224
|
-
`Errno::ENOENT`.
|
273
|
+
*Peter Zhu*
|
225
274
|
|
226
|
-
|
275
|
+
* Make services aware of configuration names.
|
227
276
|
|
228
|
-
*
|
229
|
-
`ActiveStorage::FileNotFoundError` when the corresponding file is missing
|
230
|
-
from the storage service. Services translate service-specific missing object
|
231
|
-
exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and
|
232
|
-
`Errno::ENOENT` for the disk service) into
|
233
|
-
`ActiveStorage::FileNotFoundError`.
|
277
|
+
*Gannon McGibbon*
|
234
278
|
|
235
|
-
|
279
|
+
* The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.
|
236
280
|
|
237
|
-
*
|
238
|
-
controllers that can't inherit from `ActiveStorage::BaseController`.
|
281
|
+
*Kyle Ribordy*
|
239
282
|
|
240
|
-
|
283
|
+
* Allow storage services to be configured per attachment.
|
241
284
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
285
|
+
```ruby
|
286
|
+
class User < ActiveRecord::Base
|
287
|
+
has_one_attached :avatar, service: :s3
|
288
|
+
end
|
246
289
|
|
247
|
-
|
290
|
+
class Gallery < ActiveRecord::Base
|
291
|
+
has_many_attached :photos, service: :s3
|
292
|
+
end
|
293
|
+
```
|
248
294
|
|
249
|
-
*
|
250
|
-
is saved instead of immediately.
|
295
|
+
*Dmitry Tsepelev*
|
251
296
|
|
252
|
-
|
253
|
-
be stored:
|
297
|
+
* You can optionally provide a custom blob key when attaching a new file:
|
254
298
|
|
255
299
|
```ruby
|
256
|
-
|
300
|
+
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
301
|
+
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
257
302
|
```
|
258
303
|
|
259
|
-
|
304
|
+
Active Storage will store the blob's data on the configured service at the provided key.
|
260
305
|
|
261
306
|
*George Claghorn*
|
262
307
|
|
263
|
-
*
|
264
|
-
ActiveRecord reflection mechanism.
|
308
|
+
* Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
|
265
309
|
|
266
|
-
|
310
|
+
`create_after_upload!` has been removed since it could lead to data
|
311
|
+
corruption by uploading to a key on the storage service which happened to
|
312
|
+
be already taken. Creating the record would then correctly raise a
|
313
|
+
database uniqueness exception but the stored object would already have
|
314
|
+
overwritten another. `create_and_upload!` swaps the order of operations
|
315
|
+
so that the key gets reserved up-front or the uniqueness error gets raised,
|
316
|
+
before the upload to a key takes place.
|
267
317
|
|
268
|
-
*
|
269
|
-
processor. For example, the following will not have the monochrome
|
270
|
-
variation applied:
|
318
|
+
*Julik Tarkhanov*
|
271
319
|
|
272
|
-
|
273
|
-
avatar.variant(monochrome: false)
|
274
|
-
```
|
320
|
+
* Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
|
275
321
|
|
276
|
-
*
|
322
|
+
*Peter Zhu*
|
277
323
|
|
278
|
-
*
|
279
|
-
|
280
|
-
allow overriding and composition using `super`.
|
324
|
+
* Allow record to be optionally passed to blob finders to make sharding
|
325
|
+
easier.
|
281
326
|
|
282
|
-
*
|
327
|
+
*Gannon McGibbon*
|
283
328
|
|
284
|
-
*
|
285
|
-
and yields the tempfile. Deprecate `ActiveStorage::Downloading`.
|
329
|
+
* Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
|
286
330
|
|
287
|
-
*
|
331
|
+
*Peter Zhu*
|
288
332
|
|
289
|
-
*
|
290
|
-
`ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
|
291
|
-
type inference. For example:
|
333
|
+
* Add `config.active_storage.draw_routes` to disable Active Storage routes.
|
292
334
|
|
293
|
-
|
294
|
-
@message.image.attach(
|
295
|
-
io: File.open('/path/to/file'),
|
296
|
-
filename: 'file.pdf',
|
297
|
-
content_type: 'application/pdf',
|
298
|
-
identify: false
|
299
|
-
)
|
300
|
-
```
|
335
|
+
*Gannon McGibbon*
|
301
336
|
|
302
|
-
|
337
|
+
* Image analysis is skipped if ImageMagick returns an error.
|
303
338
|
|
304
|
-
|
305
|
-
|
339
|
+
`ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
|
340
|
+
`MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
|
341
|
+
failures. It now logs the error and returns `{}`, resulting in no metadata
|
342
|
+
being added to the offending image blob.
|
306
343
|
|
307
344
|
*George Claghorn*
|
308
345
|
|
309
|
-
*
|
310
|
-
for Active Storage variants, and deprecate the MiniMagick backend.
|
346
|
+
* Method calls on singular attachments return `nil` when no file is attached.
|
311
347
|
|
312
|
-
|
313
|
-
|
314
|
-
operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
|
315
|
-
other ImageProcessing macros. These are now recommended over raw `:resize`,
|
316
|
-
as they also sharpen the thumbnail after resizing.
|
348
|
+
Previously, assuming the following User model, `user.avatar.filename` would
|
349
|
+
raise a `Module::DelegationError` if no avatar was attached:
|
317
350
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
351
|
+
```ruby
|
352
|
+
class User < ApplicationRecord
|
353
|
+
has_one_attached :avatar
|
354
|
+
end
|
355
|
+
```
|
356
|
+
|
357
|
+
They now return `nil`.
|
358
|
+
|
359
|
+
*Matthew Tanous*
|
325
360
|
|
326
|
-
|
361
|
+
* The mirror service supports direct uploads.
|
327
362
|
|
328
|
-
|
363
|
+
New files are directly uploaded to the primary service. When a
|
364
|
+
directly-uploaded file is attached to a record, a background job is enqueued
|
365
|
+
to copy it to each secondary service.
|
329
366
|
|
330
|
-
|
367
|
+
Configure the queue used to process mirroring jobs by setting
|
368
|
+
`config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
|
369
|
+
|
370
|
+
*George Claghorn*
|
371
|
+
|
372
|
+
* The S3 service now permits uploading files larger than 5 gigabytes.
|
373
|
+
|
374
|
+
When uploading a file greater than 100 megabytes in size, the service
|
375
|
+
transparently switches to [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
|
376
|
+
using a part size computed from the file's total size and S3's part count limit.
|
377
|
+
|
378
|
+
No application changes are necessary to take advantage of this feature. You
|
379
|
+
can customize the default 100 MB multipart upload threshold in your S3
|
380
|
+
service's configuration:
|
381
|
+
|
382
|
+
```yaml
|
383
|
+
production:
|
384
|
+
service: s3
|
385
|
+
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
386
|
+
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
387
|
+
region: us-east-1
|
388
|
+
bucket: my-bucket
|
389
|
+
upload:
|
390
|
+
multipart_threshold: <%= 250.megabytes %>
|
391
|
+
```
|
392
|
+
|
393
|
+
*George Claghorn*
|
331
394
|
|
332
395
|
|
333
|
-
Please check [
|
396
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activestorage/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ A key difference to how Active Storage works compared to other attachment soluti
|
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
|
-
Run `rails active_storage:install` to copy over active_storage migrations.
|
19
|
+
Run `bin/rails active_storage:install` to copy over active_storage migrations.
|
20
20
|
|
21
21
|
NOTE: If the task cannot be found, verify that `require "active_storage/engine"` is present in `config/application.rb`.
|
22
22
|
|
@@ -55,7 +55,7 @@ url_for(user.avatar)
|
|
55
55
|
|
56
56
|
class AvatarsController < ApplicationController
|
57
57
|
def update
|
58
|
-
# params[:avatar] contains
|
58
|
+
# params[:avatar] contains an ActionDispatch::Http::UploadedFile object
|
59
59
|
Current.user.avatar.attach(params.require(:avatar))
|
60
60
|
redirect_to Current.user
|
61
61
|
end
|
@@ -106,6 +106,37 @@ Variation of image attachment:
|
|
106
106
|
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100]) %>
|
107
107
|
```
|
108
108
|
|
109
|
+
## File serving strategies
|
110
|
+
|
111
|
+
Active Storage supports two ways to serve files: redirecting and proxying.
|
112
|
+
|
113
|
+
### Redirecting
|
114
|
+
|
115
|
+
Active Storage generates stable application URLs for files which, when accessed, redirect to signed, short-lived service URLs. This relieves application servers of the burden of serving file data. It is the default file serving strategy.
|
116
|
+
|
117
|
+
When the application is configured to proxy files by default, use the `rails_storage_redirect_path` and `_url` route helpers to redirect instead:
|
118
|
+
|
119
|
+
```erb
|
120
|
+
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
121
|
+
```
|
122
|
+
|
123
|
+
### Proxying
|
124
|
+
|
125
|
+
Optionally, files can be proxied instead. This means that your application servers will download file data from the storage service in response to requests. This can be useful for serving files from a CDN.
|
126
|
+
|
127
|
+
Explicitly proxy attachments using the `rails_storage_proxy_path` and `_url` route helpers:
|
128
|
+
|
129
|
+
```erb
|
130
|
+
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
131
|
+
```
|
132
|
+
|
133
|
+
Or configure Active Storage to use proxying by default:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
# config/initializers/active_storage.rb
|
137
|
+
Rails.application.config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
138
|
+
```
|
139
|
+
|
109
140
|
## Direct uploads
|
110
141
|
|
111
142
|
Active Storage, with its included JavaScript library, supports uploading directly from the client to the cloud.
|
@@ -120,7 +151,8 @@ Active Storage, with its included JavaScript library, supports uploading directl
|
|
120
151
|
```
|
121
152
|
Using the npm package:
|
122
153
|
```js
|
123
|
-
|
154
|
+
import * as ActiveStorage from "@rails/activestorage"
|
155
|
+
ActiveStorage.start()
|
124
156
|
```
|
125
157
|
2. Annotate file inputs with the direct upload URL.
|
126
158
|
|
@@ -5,4 +5,15 @@ class ActiveStorage::BaseController < ActionController::Base
|
|
5
5
|
include ActiveStorage::SetCurrent
|
6
6
|
|
7
7
|
protect_from_forgery with: :exception
|
8
|
+
|
9
|
+
self.etag_with_template_digest = false
|
10
|
+
|
11
|
+
private
|
12
|
+
def stream(blob)
|
13
|
+
blob.download do |chunk|
|
14
|
+
response.stream.write chunk
|
15
|
+
end
|
16
|
+
ensure
|
17
|
+
response.stream.close
|
18
|
+
end
|
8
19
|
end
|