activestorage 6.1.5 → 7.0.3
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 +181 -208
- data/README.md +25 -11
- data/app/assets/javascripts/activestorage.esm.js +844 -0
- data/app/assets/javascripts/activestorage.js +257 -376
- data/app/controllers/active_storage/base_controller.rb +0 -9
- data/app/controllers/active_storage/blobs/proxy_controller.rb +15 -4
- data/app/controllers/active_storage/blobs/redirect_controller.rb +6 -4
- data/app/controllers/active_storage/disk_controller.rb +1 -0
- data/app/controllers/active_storage/representations/base_controller.rb +5 -1
- data/app/controllers/active_storage/representations/proxy_controller.rb +7 -3
- data/app/controllers/active_storage/representations/redirect_controller.rb +6 -4
- data/app/controllers/concerns/active_storage/set_blob.rb +6 -2
- data/app/controllers/concerns/active_storage/set_current.rb +3 -3
- data/app/controllers/concerns/active_storage/streaming.rb +65 -0
- data/app/javascript/activestorage/ujs.js +1 -1
- data/app/models/active_storage/attachment.rb +35 -2
- data/app/models/active_storage/blob/representable.rb +7 -5
- data/app/models/active_storage/blob.rb +92 -36
- data/app/models/active_storage/current.rb +12 -2
- data/app/models/active_storage/preview.rb +6 -4
- data/app/models/active_storage/record.rb +1 -1
- data/app/models/active_storage/variant.rb +3 -6
- data/app/models/active_storage/variant_record.rb +2 -0
- data/app/models/active_storage/variant_with_record.rb +9 -5
- data/app/models/active_storage/variation.rb +2 -2
- data/config/routes.rb +10 -10
- data/db/migrate/20170806125915_create_active_storage_tables.rb +32 -11
- data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +4 -0
- data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +17 -2
- data/db/update_migrate/20211119233751_remove_not_null_on_active_storage_blobs_checksum.rb +7 -0
- data/lib/active_storage/analyzer/audio_analyzer.rb +65 -0
- data/lib/active_storage/analyzer/image_analyzer/image_magick.rb +39 -0
- data/lib/active_storage/analyzer/image_analyzer/vips.rb +49 -0
- data/lib/active_storage/analyzer/image_analyzer.rb +2 -30
- data/lib/active_storage/analyzer/video_analyzer.rb +27 -12
- data/lib/active_storage/analyzer.rb +8 -4
- data/lib/active_storage/attached/changes/create_many.rb +7 -3
- data/lib/active_storage/attached/changes/create_one.rb +1 -1
- data/lib/active_storage/attached/changes/create_one_of_many.rb +1 -1
- data/lib/active_storage/attached/changes/delete_many.rb +1 -1
- data/lib/active_storage/attached/changes/delete_one.rb +1 -1
- data/lib/active_storage/attached/changes/detach_many.rb +18 -0
- data/lib/active_storage/attached/changes/detach_one.rb +24 -0
- data/lib/active_storage/attached/changes/purge_many.rb +27 -0
- data/lib/active_storage/attached/changes/purge_one.rb +27 -0
- data/lib/active_storage/attached/changes.rb +7 -1
- data/lib/active_storage/attached/many.rb +27 -15
- data/lib/active_storage/attached/model.rb +35 -7
- data/lib/active_storage/attached/one.rb +32 -27
- data/lib/active_storage/downloader.rb +4 -4
- data/lib/active_storage/engine.rb +59 -17
- data/lib/active_storage/fixture_set.rb +76 -0
- data/lib/active_storage/gem_version.rb +4 -4
- data/lib/active_storage/previewer.rb +4 -4
- data/lib/active_storage/reflection.rb +12 -2
- data/lib/active_storage/service/azure_storage_service.rb +28 -6
- data/lib/active_storage/service/configurator.rb +1 -1
- data/lib/active_storage/service/disk_service.rb +24 -19
- data/lib/active_storage/service/gcs_service.rb +109 -11
- data/lib/active_storage/service/mirror_service.rb +2 -2
- data/lib/active_storage/service/registry.rb +1 -1
- data/lib/active_storage/service/s3_service.rb +37 -15
- data/lib/active_storage/service.rb +13 -5
- data/lib/active_storage/transformers/image_processing_transformer.rb +7 -294
- data/lib/active_storage/transformers/transformer.rb +1 -1
- data/lib/active_storage/version.rb +1 -1
- data/lib/active_storage.rb +293 -1
- metadata +28 -18
- data/app/controllers/concerns/active_storage/set_headers.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb27c3976b612802226ea7343ba6bd9483eb635f1785a0255d8048f936c77fc0
|
4
|
+
data.tar.gz: f4bea0eb4dad8afe87aa78185cb3a9eaa92e7c4eb4bd50a28f5505dba4574a6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24ef173da37fd9a08160b3ca83e78633a2f54699c6043ac7c21bf111226c1d94e6f7971acb3c2be035320cbfd6dfae9dd91c85abaaf0f97c922c33e1f5b26043
|
7
|
+
data.tar.gz: 640a260bf6d6bc690491fe365e810117232c3be9c96112ddc9a5d8e68d8d8f680930f3ae065fcaedadb43490de63a3226e8f5cbde1279419d9f23a019e692b7f
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.3 (May 09, 2022) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Don't stream responses in redirect mode
|
4
4
|
|
5
|
-
|
5
|
+
Previously, both redirect mode and proxy mode streamed their
|
6
|
+
responses which caused a new thread to be created, and could end
|
7
|
+
up leaking connections in the connection pool. But since redirect
|
8
|
+
mode doesn't actually send any data, it doesn't need to be
|
9
|
+
streamed.
|
6
10
|
|
7
|
-
*
|
11
|
+
*Luke Lau*
|
12
|
+
|
13
|
+
## Rails 7.0.2.4 (April 26, 2022) ##
|
14
|
+
|
15
|
+
* No changes.
|
8
16
|
|
9
17
|
|
10
|
-
## Rails
|
18
|
+
## Rails 7.0.2.3 (March 08, 2022) ##
|
11
19
|
|
12
20
|
* Added image transformation validation via configurable allow-list.
|
13
21
|
|
@@ -17,339 +25,304 @@
|
|
17
25
|
[CVE-2022-21831]
|
18
26
|
|
19
27
|
|
20
|
-
## Rails
|
28
|
+
## Rails 7.0.2.2 (February 11, 2022) ##
|
21
29
|
|
22
30
|
* No changes.
|
23
31
|
|
24
|
-
|
25
|
-
## Rails 6.1.4.5 (February 11, 2022) ##
|
32
|
+
## Rails 7.0.2.1 (February 11, 2022) ##
|
26
33
|
|
27
34
|
* No changes.
|
28
35
|
|
29
36
|
|
30
|
-
## Rails
|
31
|
-
|
32
|
-
* No changes.
|
37
|
+
## Rails 7.0.2 (February 08, 2022) ##
|
33
38
|
|
39
|
+
* Revert the ability to pass `service_name` param to `DirectUploadsController` which was introduced
|
40
|
+
in 7.0.0.
|
34
41
|
|
35
|
-
|
36
|
-
|
37
|
-
* No changes.
|
42
|
+
That change caused a lot of problems to upgrade Rails applications so we decided to remove it
|
43
|
+
while in work in a more backwards compatible implementation.
|
38
44
|
|
45
|
+
*Gannon McGibbon*
|
39
46
|
|
40
|
-
|
47
|
+
* Allow applications to opt out of precompiling Active Storage JavaScript assets.
|
41
48
|
|
42
|
-
*
|
49
|
+
*jlestavel*
|
43
50
|
|
44
51
|
|
45
|
-
## Rails
|
52
|
+
## Rails 7.0.1 (January 06, 2022) ##
|
46
53
|
|
47
54
|
* No changes.
|
48
55
|
|
49
56
|
|
50
|
-
## Rails
|
51
|
-
|
52
|
-
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
53
|
-
configurable under `config.active_storage.video_preview_arguments`.
|
57
|
+
## Rails 7.0.0 (December 15, 2021) ##
|
54
58
|
|
55
|
-
|
59
|
+
* Support transforming empty-ish `has_many_attached` value into `[]` (e.g. `[""]`).
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
* Don't raise an error if the mime type is not recognized.
|
62
|
-
|
63
|
-
Fixes #41777.
|
64
|
-
|
65
|
-
*Alex Ghiculescu*
|
66
|
-
|
67
|
-
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
68
|
-
|
69
|
-
*Alex Robbin*
|
70
|
-
|
71
|
-
* respond with 404 given invalid variation key when asking for representations.
|
72
|
-
|
73
|
-
*George Claghorn*
|
74
|
-
|
75
|
-
* `Blob` creation shouldn't crash if no service selected.
|
76
|
-
|
77
|
-
*Alex Ghiculescu*
|
78
|
-
|
79
|
-
|
80
|
-
## Rails 6.1.3.2 (May 05, 2021) ##
|
81
|
-
|
82
|
-
* No changes.
|
83
|
-
|
84
|
-
|
85
|
-
## Rails 6.1.3.1 (March 26, 2021) ##
|
86
|
-
|
87
|
-
* Marcel is upgraded to version 1.0.0 to avoid a dependency on GPL-licensed
|
88
|
-
mime types data.
|
61
|
+
```ruby
|
62
|
+
@user.highlights = [""]
|
63
|
+
@user.highlights # => []
|
64
|
+
```
|
89
65
|
|
90
|
-
|
66
|
+
*Sean Doyle*
|
91
67
|
|
92
68
|
|
93
|
-
## Rails
|
69
|
+
## Rails 7.0.0.rc3 (December 14, 2021) ##
|
94
70
|
|
95
71
|
* No changes.
|
96
72
|
|
97
73
|
|
98
|
-
## Rails
|
74
|
+
## Rails 7.0.0.rc2 (December 14, 2021) ##
|
99
75
|
|
100
76
|
* No changes.
|
101
77
|
|
78
|
+
## Rails 7.0.0.rc1 (December 06, 2021) ##
|
102
79
|
|
103
|
-
|
80
|
+
* `Add ActiveStorage::Blob.compose` to concatenate multiple blobs.
|
104
81
|
|
105
|
-
*
|
82
|
+
*Gannon McGibbon*
|
106
83
|
|
84
|
+
* Setting custom metadata on blobs are now persisted to remote storage.
|
107
85
|
|
108
|
-
|
86
|
+
*joshuamsager*
|
109
87
|
|
110
|
-
*
|
88
|
+
* Support direct uploads to multiple services.
|
111
89
|
|
112
|
-
*
|
90
|
+
*Dmitry Tsepelev*
|
113
91
|
|
92
|
+
* Invalid default content types are deprecated
|
114
93
|
|
115
|
-
|
94
|
+
Blobs created with content_type `image/jpg`, `image/pjpeg`, `image/bmp`, `text/javascript` will now produce
|
95
|
+
a deprecation warning, since these are not valid content types.
|
116
96
|
|
117
|
-
|
118
|
-
purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).
|
97
|
+
These content types will be removed from the defaults in Rails 7.1.
|
119
98
|
|
120
|
-
|
99
|
+
You can set `config.active_storage.silence_invalid_content_types_warning = true` to dismiss the warning.
|
121
100
|
|
122
|
-
*
|
101
|
+
*Alex Ghiculescu*
|
123
102
|
|
124
|
-
|
103
|
+
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
125
104
|
|
126
|
-
*
|
105
|
+
* No changes.
|
127
106
|
|
128
|
-
*Rafael Mendonça França*
|
129
107
|
|
130
|
-
|
108
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
131
109
|
|
132
|
-
|
110
|
+
* Emit Active Support instrumentation events from Active Storage analyzers.
|
133
111
|
|
134
|
-
|
112
|
+
Fixes #42930
|
135
113
|
|
136
|
-
*
|
114
|
+
*Shouichi Kamiya*
|
137
115
|
|
138
|
-
*
|
116
|
+
* Add support for byte range requests
|
139
117
|
|
140
|
-
*
|
118
|
+
*Tom Prats*
|
141
119
|
|
142
|
-
*
|
120
|
+
* Attachments can be deleted after their association is no longer defined.
|
143
121
|
|
144
|
-
|
122
|
+
Fixes #42514
|
145
123
|
|
146
|
-
*
|
147
|
-
document's crop box rather than its media box, hiding print margins. This
|
148
|
-
matches the behavior of the MuPDF previewer.
|
124
|
+
*Don Sisco*
|
149
125
|
|
150
|
-
|
126
|
+
* Make `vips` the default variant processor for new apps.
|
151
127
|
|
152
|
-
|
128
|
+
See the upgrade guide for instructions on converting from `mini_magick` to `vips`. `mini_magick` is
|
129
|
+
not deprecated, existing apps can keep using it.
|
153
130
|
|
154
|
-
*
|
131
|
+
*Breno Gazzola*
|
155
132
|
|
156
|
-
*
|
157
|
-
|
158
|
-
`rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
|
133
|
+
* Deprecate `ActiveStorage::Current.host` in favor of `ActiveStorage::Current.url_options` which accepts
|
134
|
+
a host, protocol and port.
|
159
135
|
|
160
|
-
|
161
|
-
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
162
|
-
```
|
136
|
+
*Santiago Bartesaghi*
|
163
137
|
|
164
|
-
|
138
|
+
* Allow using [IAM](https://cloud.google.com/storage/docs/access-control/signed-urls) when signing URLs with GCS.
|
165
139
|
|
166
|
-
```
|
167
|
-
|
168
|
-
|
140
|
+
```yaml
|
141
|
+
gcs:
|
142
|
+
service: GCS
|
143
|
+
...
|
144
|
+
iam: true
|
169
145
|
```
|
170
146
|
|
171
|
-
|
172
|
-
<%= image_tag @user.avatar %>
|
173
|
-
```
|
147
|
+
*RRethy*
|
174
148
|
|
175
|
-
|
176
|
-
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
149
|
+
* OpenSSL constants are now used for Digest computations.
|
177
150
|
|
178
|
-
|
179
|
-
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
180
|
-
```
|
151
|
+
*Dirkjan Bussink*
|
181
152
|
|
182
|
-
|
153
|
+
* Deprecate `config.active_storage.replace_on_assign_to_many`. Future versions of Rails
|
154
|
+
will behave the same way as when the config is set to `true`.
|
183
155
|
|
184
|
-
*
|
185
|
-
to add content types (like `image/webp`) in which variants can be processed,
|
186
|
-
instead of letting those images be converted to the fallback PNG format.
|
156
|
+
*Santiago Bartesaghi*
|
187
157
|
|
188
|
-
|
158
|
+
* Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
|
159
|
+
and `service_url` in favor of `url`.
|
189
160
|
|
190
|
-
*
|
161
|
+
*Santiago Bartesaghi*
|
191
162
|
|
192
|
-
|
163
|
+
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
|
193
164
|
|
194
|
-
*
|
165
|
+
*Anton Topchii*, *Andrew White*
|
195
166
|
|
196
|
-
|
167
|
+
* Allow to detach an attachment when record is not persisted.
|
197
168
|
|
198
|
-
*
|
169
|
+
*Jacopo Beschi*
|
199
170
|
|
200
|
-
|
171
|
+
* Use libvips instead of ImageMagick to analyze images when `active_storage.variant_processor = vips`.
|
201
172
|
|
202
|
-
*
|
173
|
+
*Breno Gazzola*
|
203
174
|
|
204
|
-
|
175
|
+
* Add metadata value for presence of video channel in video blobs.
|
205
176
|
|
206
|
-
|
177
|
+
The `metadata` attribute of video blobs has a new boolean key named `video` that is set to
|
178
|
+
`true` if the file has an video channel and `false` if it doesn't.
|
207
179
|
|
208
|
-
|
209
|
-
`service_name` field in the generated URL in `DiskService`.
|
180
|
+
*Breno Gazzola*
|
210
181
|
|
211
|
-
|
182
|
+
* Deprecate usage of `purge` and `purge_later` from the association extension.
|
212
183
|
|
213
|
-
*
|
184
|
+
*Jacopo Beschi*
|
214
185
|
|
215
|
-
|
186
|
+
* Passing extra parameters in `ActiveStorage::Blob#url` to S3 Client.
|
216
187
|
|
217
|
-
|
188
|
+
This allows calls of `ActiveStorage::Blob#url` to have more interaction with
|
189
|
+
the S3 Presigner, enabling, amongst other options, custom S3 domain URL
|
190
|
+
Generation.
|
218
191
|
|
219
|
-
|
220
|
-
|
192
|
+
```ruby
|
193
|
+
blob = ActiveStorage::Blob.last
|
221
194
|
|
222
|
-
|
195
|
+
blob.url # => https://<bucket-name>.s3.<region>.amazonaws.com/<key>
|
196
|
+
blob.url(virtual_host: true) # => # => https://<bucket-name>/<key>
|
197
|
+
```
|
223
198
|
|
224
|
-
*
|
199
|
+
*josegomezr*
|
225
200
|
|
226
|
-
|
227
|
-
`public: true | false` to indicate whether a service holds public
|
228
|
-
blobs or private blobs. Public services will always return a permanent URL.
|
201
|
+
* Allow setting a `Cache-Control` on files uploaded to GCS.
|
229
202
|
|
230
|
-
|
203
|
+
```yaml
|
204
|
+
gcs:
|
205
|
+
service: GCS
|
206
|
+
...
|
207
|
+
cache_control: "public, max-age=3600"
|
208
|
+
```
|
231
209
|
|
232
|
-
*
|
210
|
+
*maleblond*
|
233
211
|
|
234
|
-
*
|
212
|
+
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
213
|
+
configurable under `config.active_storage.video_preview_arguments`.
|
235
214
|
|
236
|
-
*
|
215
|
+
*Brendon Muir*
|
237
216
|
|
238
|
-
* The
|
217
|
+
* The ActiveStorage video previewer will now use scene change detection to generate
|
218
|
+
better preview images (rather than the previous default of using the first frame
|
219
|
+
of the video). This change requires FFmpeg v3.4+.
|
239
220
|
|
240
|
-
*
|
221
|
+
*Jonathan Hefner*
|
241
222
|
|
242
|
-
*
|
223
|
+
* Add support for ActiveStorage expiring URLs.
|
243
224
|
|
244
225
|
```ruby
|
245
|
-
|
246
|
-
has_one_attached :avatar, service: :s3
|
247
|
-
end
|
226
|
+
rails_blob_path(user.avatar, disposition: "attachment", expires_in: 30.minutes)
|
248
227
|
|
249
|
-
|
250
|
-
has_many_attached :photos, service: :s3
|
251
|
-
end
|
228
|
+
<%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_in: 30.minutes) %>
|
252
229
|
```
|
253
230
|
|
254
|
-
|
231
|
+
If you want to set default expiration time for ActiveStorage URLs throughout your application, set `config.active_storage.urls_expire_in`.
|
255
232
|
|
256
|
-
*
|
233
|
+
*aki77*
|
257
234
|
|
258
|
-
|
259
|
-
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
260
|
-
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
261
|
-
```
|
235
|
+
* Allow to purge an attachment when record is not persisted for `has_many_attached`.
|
262
236
|
|
263
|
-
|
237
|
+
*Jacopo Beschi*
|
264
238
|
|
265
|
-
|
239
|
+
* Add `with_all_variant_records` method to eager load all variant records on an attachment at once.
|
240
|
+
`with_attached_image` scope now eager loads variant records if using variant tracking.
|
266
241
|
|
267
|
-
*
|
242
|
+
*Alex Ghiculescu*
|
268
243
|
|
269
|
-
|
270
|
-
corruption by uploading to a key on the storage service which happened to
|
271
|
-
be already taken. Creating the record would then correctly raise a
|
272
|
-
database uniqueness exception but the stored object would already have
|
273
|
-
overwritten another. `create_and_upload!` swaps the order of operations
|
274
|
-
so that the key gets reserved up-front or the uniqueness error gets raised,
|
275
|
-
before the upload to a key takes place.
|
244
|
+
* Add metadata value for presence of audio channel in video blobs.
|
276
245
|
|
277
|
-
|
246
|
+
The `metadata` attribute of video blobs has a new boolean key named `audio` that is set to
|
247
|
+
`true` if the file has an audio channel and `false` if it doesn't.
|
278
248
|
|
279
|
-
*
|
249
|
+
*Breno Gazzola*
|
280
250
|
|
281
|
-
|
251
|
+
* Adds analyzer for audio files.
|
282
252
|
|
283
|
-
*
|
284
|
-
easier.
|
253
|
+
*Breno Gazzola*
|
285
254
|
|
286
|
-
|
255
|
+
* Respect Active Record's primary_key_type in Active Storage migrations.
|
287
256
|
|
288
|
-
*
|
257
|
+
*fatkodima*
|
289
258
|
|
290
|
-
|
259
|
+
* Allow `expires_in` for ActiveStorage signed ids.
|
291
260
|
|
292
|
-
*
|
261
|
+
*aki77*
|
293
262
|
|
294
|
-
|
263
|
+
* Allow to purge an attachment when record is not persisted for `has_one_attached`.
|
295
264
|
|
296
|
-
*
|
265
|
+
*Jacopo Beschi*
|
297
266
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
267
|
+
* Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
|
268
|
+
to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
|
269
|
+
`ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
|
270
|
+
that already have load hooks.
|
302
271
|
|
303
|
-
*
|
272
|
+
*Brendon Muir*
|
304
273
|
|
305
|
-
*
|
274
|
+
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
306
275
|
|
307
|
-
|
308
|
-
|
276
|
+
*Alex Robbin*
|
277
|
+
|
278
|
+
* Add `ActiveStorage::Streaming` module that can be included in a controller to get access to `#send_blob_stream`,
|
279
|
+
which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
|
309
280
|
|
310
281
|
```ruby
|
311
|
-
class
|
312
|
-
|
282
|
+
class MyPublicBlobsController < ApplicationController
|
283
|
+
include ActiveStorage::SetBlob, ActiveStorage::Streaming
|
284
|
+
|
285
|
+
def show
|
286
|
+
http_cache_forever(public: true) do
|
287
|
+
send_blob_stream @blob, disposition: params[:disposition]
|
288
|
+
end
|
289
|
+
end
|
313
290
|
end
|
314
291
|
```
|
315
292
|
|
316
|
-
|
317
|
-
|
318
|
-
*Matthew Tanous*
|
293
|
+
*DHH*
|
319
294
|
|
320
|
-
*
|
295
|
+
* Add ability to use pre-defined variants.
|
321
296
|
|
322
|
-
|
323
|
-
|
324
|
-
|
297
|
+
```ruby
|
298
|
+
class User < ActiveRecord::Base
|
299
|
+
has_one_attached :avatar do |attachable|
|
300
|
+
attachable.variant :thumb, resize: "100x100"
|
301
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
302
|
+
end
|
303
|
+
end
|
325
304
|
|
326
|
-
|
327
|
-
|
305
|
+
class Gallery < ActiveRecord::Base
|
306
|
+
has_many_attached :photos do |attachable|
|
307
|
+
attachable.variant :thumb, resize: "100x100"
|
308
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
309
|
+
end
|
310
|
+
end
|
328
311
|
|
329
|
-
|
312
|
+
<%= image_tag user.avatar.variant(:thumb) %>
|
313
|
+
```
|
330
314
|
|
331
|
-
*
|
315
|
+
*fatkodima*
|
332
316
|
|
333
|
-
|
334
|
-
|
335
|
-
using a part size computed from the file's total size and S3's part count limit.
|
317
|
+
* After setting `config.active_storage.resolve_model_to_route = :rails_storage_proxy`
|
318
|
+
`rails_blob_path` and `rails_representation_path` will generate proxy URLs by default.
|
336
319
|
|
337
|
-
|
338
|
-
can customize the default 100 MB multipart upload threshold in your S3
|
339
|
-
service's configuration:
|
320
|
+
*Ali Ismayilov*
|
340
321
|
|
341
|
-
|
342
|
-
|
343
|
-
service: s3
|
344
|
-
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
345
|
-
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
346
|
-
region: us-east-1
|
347
|
-
bucket: my-bucket
|
348
|
-
upload:
|
349
|
-
multipart_threshold: <%= 250.megabytes %>
|
350
|
-
```
|
322
|
+
* Declare `ActiveStorage::FixtureSet` and `ActiveStorage::FixtureSet.blob` to
|
323
|
+
improve fixture integration.
|
351
324
|
|
352
|
-
*
|
325
|
+
*Sean Doyle*
|
353
326
|
|
354
327
|
|
355
|
-
Please check [6-
|
328
|
+
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activestorage/CHANGELOG.md) for previous changes.
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ class User < ApplicationRecord
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# Attach an avatar to the user.
|
35
|
-
user.avatar.attach(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/
|
35
|
+
user.avatar.attach(io: File.open("/path/to/face.jpg"), filename: "face.jpg", content_type: "image/jpeg")
|
36
36
|
|
37
37
|
# Does the user have an avatar?
|
38
38
|
user.avatar.attached? # => true
|
@@ -88,8 +88,7 @@ class MessagesController < ApplicationController
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def create
|
91
|
-
message = Message.create! params.require(:message).permit(:title, :content)
|
92
|
-
message.images.attach(params[:message][:images])
|
91
|
+
message = Message.create! params.require(:message).permit(:title, :content, images: [])
|
93
92
|
redirect_to message
|
94
93
|
end
|
95
94
|
|
@@ -124,27 +123,42 @@ When the application is configured to proxy files by default, use the `rails_sto
|
|
124
123
|
|
125
124
|
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
125
|
|
127
|
-
|
128
|
-
|
129
|
-
```erb
|
130
|
-
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
131
|
-
```
|
132
|
-
|
133
|
-
Or configure Active Storage to use proxying by default:
|
126
|
+
You can configure Active Storage to use proxying by default:
|
134
127
|
|
135
128
|
```ruby
|
136
129
|
# config/initializers/active_storage.rb
|
137
130
|
Rails.application.config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
138
131
|
```
|
139
132
|
|
133
|
+
Or if you want to explicitly proxy specific attachments there are URL helpers you can use in the form of `rails_storage_proxy_path` and `rails_storage_proxy_url`.
|
134
|
+
|
135
|
+
```erb
|
136
|
+
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
137
|
+
```
|
138
|
+
|
140
139
|
## Direct uploads
|
141
140
|
|
142
141
|
Active Storage, with its included JavaScript library, supports uploading directly from the client to the cloud.
|
143
142
|
|
144
143
|
### Direct upload installation
|
145
144
|
|
146
|
-
1. Include
|
145
|
+
1. Include the Active Storage JavaScript in your application's JavaScript bundle or reference it directly.
|
147
146
|
|
147
|
+
Requiring directly without bundling through the asset pipeline in the application html with autostart:
|
148
|
+
```html
|
149
|
+
<%= javascript_include_tag "activestorage" %>
|
150
|
+
```
|
151
|
+
Requiring via importmap-rails without bundling through the asset pipeline in the application html without autostart as ESM:
|
152
|
+
```ruby
|
153
|
+
# config/importmap.rb
|
154
|
+
pin "@rails/activestorage", to: "activestorage.esm.js"
|
155
|
+
```
|
156
|
+
```html
|
157
|
+
<script type="module-shim">
|
158
|
+
import * as ActiveStorage from "@rails/activestorage"
|
159
|
+
ActiveStorage.start()
|
160
|
+
</script>
|
161
|
+
```
|
148
162
|
Using the asset pipeline:
|
149
163
|
```js
|
150
164
|
//= require activestorage
|