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