activestorage 6.1.6 → 7.0.0.alpha1
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 +129 -268
- data/MIT-LICENSE +1 -1
- 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 +1 -10
- data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -4
- data/app/controllers/active_storage/blobs/redirect_controller.rb +6 -4
- data/app/controllers/active_storage/representations/base_controller.rb +5 -1
- data/app/controllers/active_storage/representations/proxy_controller.rb +6 -4
- 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 +26 -27
- 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 +6 -9
- 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 +3 -3
- data/config/routes.rb +10 -10
- data/db/migrate/20170806125915_create_active_storage_tables.rb +29 -8
- data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +15 -2
- 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 +26 -11
- 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 +31 -5
- data/lib/active_storage/attached/one.rb +32 -27
- data/lib/active_storage/downloader.rb +2 -2
- data/lib/active_storage/engine.rb +28 -16
- data/lib/active_storage/fixture_set.rb +76 -0
- data/lib/active_storage/gem_version.rb +4 -4
- data/lib/active_storage/previewer/video_previewer.rb +0 -2
- 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 +1 -1
- data/lib/active_storage/service/configurator.rb +1 -1
- data/lib/active_storage/service/disk_service.rb +13 -18
- data/lib/active_storage/service/gcs_service.rb +91 -7
- data/lib/active_storage/service/mirror_service.rb +1 -1
- data/lib/active_storage/service/registry.rb +1 -1
- data/lib/active_storage/service/s3_service.rb +4 -4
- data/lib/active_storage/service.rb +3 -3
- data/lib/active_storage/transformers/image_processing_transformer.rb +1 -66
- data/lib/active_storage/transformers/transformer.rb +1 -1
- data/lib/active_storage.rb +3 -292
- metadata +32 -24
- 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: c267f362a238a90819d7e7cd23917d10970b03acd2956d099ea6aeb26c2ce192
|
4
|
+
data.tar.gz: c669f3a56d9b6f3f5a08e89cfb49725d65d1abf0d7e933c50b6a3fc12c7d9a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf96bff832fd497ff5475a475c2b8d5d22b12243d4126bd973ec28c670f9fb57e2e787c073c2ebf4edd89fb3a1d2fbd703a47e0f9a76490389b22e7e9483e2bd
|
7
|
+
data.tar.gz: a405ab97196c4b8c60f284b3e7c664ed30756a08abfe2d1f5d50c43630ec5cfd46d71dcd533e545151312f16459aec534a55f533be95aa6ee47021d29ce30466
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Emit Active Support instrumentation events from Active Storage analyzers.
|
4
4
|
|
5
|
+
Fixes #42930
|
5
6
|
|
6
|
-
|
7
|
+
*Shouichi Kamiya*
|
8
|
+
|
9
|
+
* Add support for byte range requests
|
10
|
+
|
11
|
+
*Tom Prats*
|
7
12
|
|
8
13
|
* Attachments can be deleted after their association is no longer defined.
|
9
14
|
|
@@ -11,350 +16,206 @@
|
|
11
16
|
|
12
17
|
*Don Sisco*
|
13
18
|
|
19
|
+
* Make `vips` the default variant processor for new apps.
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
* Added image transformation validation via configurable allow-list.
|
18
|
-
|
19
|
-
Variant now offers a configurable allow-list for
|
20
|
-
transformation methods in addition to a configurable deny-list for arguments.
|
21
|
-
|
22
|
-
[CVE-2022-21831]
|
23
|
-
|
24
|
-
|
25
|
-
## Rails 6.1.4.6 (February 11, 2022) ##
|
26
|
-
|
27
|
-
* No changes.
|
28
|
-
|
29
|
-
|
30
|
-
## Rails 6.1.4.5 (February 11, 2022) ##
|
31
|
-
|
32
|
-
* No changes.
|
33
|
-
|
34
|
-
|
35
|
-
## Rails 6.1.4.4 (December 15, 2021) ##
|
36
|
-
|
37
|
-
* No changes.
|
38
|
-
|
39
|
-
|
40
|
-
## Rails 6.1.4.3 (December 14, 2021) ##
|
41
|
-
|
42
|
-
* No changes.
|
43
|
-
|
44
|
-
|
45
|
-
## Rails 6.1.4.2 (December 14, 2021) ##
|
46
|
-
|
47
|
-
* No changes.
|
48
|
-
|
49
|
-
|
50
|
-
## Rails 6.1.4.1 (August 19, 2021) ##
|
51
|
-
|
52
|
-
* No changes.
|
53
|
-
|
54
|
-
|
55
|
-
## Rails 6.1.4 (June 24, 2021) ##
|
56
|
-
|
57
|
-
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
58
|
-
configurable under `config.active_storage.video_preview_arguments`.
|
59
|
-
|
60
|
-
*Brendon Muir*
|
61
|
-
|
62
|
-
* Fix Active Storage update task when running in an engine.
|
63
|
-
|
64
|
-
*Justin Malčić*
|
65
|
-
|
66
|
-
* Don't raise an error if the mime type is not recognized.
|
67
|
-
|
68
|
-
Fixes #41777.
|
69
|
-
|
70
|
-
*Alex Ghiculescu*
|
71
|
-
|
72
|
-
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
73
|
-
|
74
|
-
*Alex Robbin*
|
21
|
+
See the upgrade guide for instructions on converting from `mini_magick` to `vips`. `mini_magick` is
|
22
|
+
not deprecated, existing apps can keep using it.
|
75
23
|
|
76
|
-
*
|
24
|
+
*Breno Gazzola*
|
77
25
|
|
78
|
-
|
79
|
-
|
80
|
-
* `Blob` creation shouldn't crash if no service selected.
|
81
|
-
|
82
|
-
*Alex Ghiculescu*
|
26
|
+
* Deprecate `ActiveStorage::Current.host` in favor of `ActiveStorage::Current.url_options` which accepts
|
27
|
+
a host, protocol and port.
|
83
28
|
|
29
|
+
*Santiago Bartesaghi*
|
84
30
|
|
85
|
-
|
31
|
+
* Allow using [IAM](https://cloud.google.com/storage/docs/access-control/signed-urls) when signing URLs with GCS.
|
86
32
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
mime types data.
|
94
|
-
|
95
|
-
*George Claghorn*
|
96
|
-
|
97
|
-
|
98
|
-
## Rails 6.1.3 (February 17, 2021) ##
|
99
|
-
|
100
|
-
* No changes.
|
101
|
-
|
102
|
-
|
103
|
-
## Rails 6.1.2.1 (February 10, 2021) ##
|
33
|
+
```yaml
|
34
|
+
gcs:
|
35
|
+
service: GCS
|
36
|
+
...
|
37
|
+
iam: true
|
38
|
+
```
|
104
39
|
|
105
|
-
*
|
40
|
+
*RRethy*
|
106
41
|
|
42
|
+
* OpenSSL constants are now used for Digest computations.
|
107
43
|
|
108
|
-
|
44
|
+
*Dirkjan Bussink*
|
109
45
|
|
110
|
-
*
|
46
|
+
* Deprecate `config.active_storage.replace_on_assign_to_many`. Future versions of Rails
|
47
|
+
will behave the same way as when the config is set to `true`.
|
111
48
|
|
49
|
+
*Santiago Bartesaghi*
|
112
50
|
|
113
|
-
|
51
|
+
* Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
|
52
|
+
and `service_url` in favor of `url`.
|
114
53
|
|
115
|
-
*
|
54
|
+
*Santiago Bartesaghi*
|
116
55
|
|
117
|
-
|
56
|
+
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
|
118
57
|
|
58
|
+
*Anton Topchii*, *Andrew White*
|
119
59
|
|
120
|
-
|
60
|
+
* Allow to detach an attachment when record is not persisted.
|
121
61
|
|
122
|
-
*
|
123
|
-
purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).
|
62
|
+
*Jacopo Beschi*
|
124
63
|
|
125
|
-
|
64
|
+
* Use libvips instead of ImageMagick to analyze images when `active_storage.variant_processor = vips`.
|
126
65
|
|
127
|
-
*
|
66
|
+
*Breno Gazzola*
|
128
67
|
|
129
|
-
|
68
|
+
* Add metadata value for presence of video channel in video blobs.
|
130
69
|
|
131
|
-
|
70
|
+
The `metadata` attribute of video blobs has a new boolean key named `video` that is set to
|
71
|
+
`true` if the file has an video channel and `false` if it doesn't.
|
132
72
|
|
133
|
-
*
|
73
|
+
*Breno Gazzola*
|
134
74
|
|
135
|
-
*
|
75
|
+
* Deprecate usage of `purge` and `purge_later` from the association extension.
|
136
76
|
|
137
|
-
*
|
77
|
+
*Jacopo Beschi*
|
138
78
|
|
139
|
-
*
|
79
|
+
* Passing extra parameters in `ActiveStorage::Blob#url` to S3 Client.
|
140
80
|
|
141
|
-
|
81
|
+
This allows calls of `ActiveStorage::Blob#url` to have more interaction with
|
82
|
+
the S3 Presigner, enabling, amongst other options, custom S3 domain URL
|
83
|
+
Generation.
|
142
84
|
|
143
|
-
|
85
|
+
```ruby
|
86
|
+
blob = ActiveStorage::Blob.last
|
144
87
|
|
145
|
-
|
88
|
+
blob.url # => https://<bucket-name>.s3.<region>.amazonaws.com/<key>
|
89
|
+
blob.url(virtual_host: true) # => # => https://<bucket-name>/<key>
|
90
|
+
```
|
146
91
|
|
147
|
-
*
|
92
|
+
*josegomezr*
|
148
93
|
|
149
|
-
|
94
|
+
* Allow setting a `Cache-Control` on files uploaded to GCS.
|
150
95
|
|
151
|
-
|
152
|
-
|
153
|
-
|
96
|
+
```yaml
|
97
|
+
gcs:
|
98
|
+
service: GCS
|
99
|
+
...
|
100
|
+
cache_control: "public, max-age=3600"
|
101
|
+
```
|
154
102
|
|
155
|
-
*
|
103
|
+
*maleblond*
|
156
104
|
|
157
|
-
*
|
105
|
+
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
106
|
+
configurable under `config.active_storage.video_preview_arguments`.
|
158
107
|
|
159
|
-
*
|
108
|
+
*Brendon Muir*
|
160
109
|
|
161
|
-
*
|
162
|
-
|
163
|
-
|
110
|
+
* The ActiveStorage video previewer will now use scene change detection to generate
|
111
|
+
better preview images (rather than the previous default of using the first frame
|
112
|
+
of the video). This change requires FFmpeg v3.4+.
|
164
113
|
|
165
|
-
|
166
|
-
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
167
|
-
```
|
114
|
+
*Jonathan Hefner*
|
168
115
|
|
169
|
-
|
116
|
+
* Add support for ActiveStorage expiring URLs.
|
170
117
|
|
171
118
|
```ruby
|
172
|
-
|
173
|
-
config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
174
|
-
```
|
119
|
+
rails_blob_path(user.avatar, disposition: "attachment", expires_in: 30.minutes)
|
175
120
|
|
176
|
-
|
177
|
-
<%= image_tag @user.avatar %>
|
121
|
+
<%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_in: 30.minutes) %>
|
178
122
|
```
|
179
123
|
|
180
|
-
|
181
|
-
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
124
|
+
If you want to set default expiration time for ActiveStorage URLs throughout your application, set `config.active_storage.urls_expire_in`.
|
182
125
|
|
183
|
-
|
184
|
-
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
185
|
-
```
|
186
|
-
|
187
|
-
*Jonathan Fleckenstein*
|
188
|
-
|
189
|
-
* Add `config.active_storage.web_image_content_types` to allow applications
|
190
|
-
to add content types (like `image/webp`) in which variants can be processed,
|
191
|
-
instead of letting those images be converted to the fallback PNG format.
|
192
|
-
|
193
|
-
*Jeroen van Haperen*
|
126
|
+
*aki77*
|
194
127
|
|
195
|
-
*
|
128
|
+
* Allow to purge an attachment when record is not persisted for `has_many_attached`.
|
196
129
|
|
197
|
-
*
|
130
|
+
*Jacopo Beschi*
|
198
131
|
|
199
|
-
*
|
132
|
+
* Add `with_all_variant_records` method to eager load all variant records on an attachment at once.
|
133
|
+
`with_attached_image` scope now eager loads variant records if using variant tracking.
|
200
134
|
|
201
|
-
*
|
202
|
-
|
203
|
-
* Previews are created on the same service as the original blob.
|
204
|
-
|
205
|
-
*Peter Zhu*
|
135
|
+
*Alex Ghiculescu*
|
206
136
|
|
207
|
-
*
|
137
|
+
* Add metadata value for presence of audio channel in video blobs.
|
208
138
|
|
209
|
-
|
139
|
+
The `metadata` attribute of video blobs has a new boolean key named `audio` that is set to
|
140
|
+
`true` if the file has an audio channel and `false` if it doesn't.
|
210
141
|
|
211
|
-
*
|
142
|
+
*Breno Gazzola*
|
212
143
|
|
213
|
-
|
214
|
-
`service_name` field in the generated URL in `DiskService`.
|
144
|
+
* Adds analyzer for audio files.
|
215
145
|
|
216
|
-
*
|
146
|
+
*Breno Gazzola*
|
217
147
|
|
218
|
-
*
|
148
|
+
* Respect Active Record's primary_key_type in Active Storage migrations.
|
219
149
|
|
220
|
-
*
|
150
|
+
*fatkodima*
|
221
151
|
|
222
|
-
*
|
152
|
+
* Allow `expires_in` for ActiveStorage signed ids.
|
223
153
|
|
224
|
-
|
225
|
-
`#url` method to be consistent with `Blob`.
|
154
|
+
*aki77*
|
226
155
|
|
227
|
-
|
156
|
+
* Allow to purge an attachment when record is not persisted for `has_one_attached`.
|
228
157
|
|
229
|
-
*
|
158
|
+
*Jacopo Beschi*
|
230
159
|
|
231
|
-
|
232
|
-
|
233
|
-
|
160
|
+
* Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
|
161
|
+
to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
|
162
|
+
`ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
|
163
|
+
that already have load hooks.
|
234
164
|
|
235
|
-
|
165
|
+
*Brendon Muir*
|
236
166
|
|
237
|
-
|
167
|
+
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
238
168
|
|
239
|
-
*
|
169
|
+
*Alex Robbin*
|
240
170
|
|
241
|
-
|
171
|
+
* Add `ActiveStorage::Streaming` module that can be included in a controller to get access to `#send_blob_stream`,
|
172
|
+
which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
|
242
173
|
|
243
|
-
|
174
|
+
```ruby
|
175
|
+
class MyPublicBlobsController < ApplicationController
|
176
|
+
include ActiveStorage::SetBlob, ActiveStorage::Streaming
|
177
|
+
|
178
|
+
def show
|
179
|
+
http_cache_forever(public: true) do
|
180
|
+
send_blob_stream @blob, disposition: params[:disposition]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
```
|
244
185
|
|
245
|
-
*
|
186
|
+
*DHH*
|
246
187
|
|
247
|
-
*
|
188
|
+
* Add ability to use pre-defined variants.
|
248
189
|
|
249
190
|
```ruby
|
250
191
|
class User < ActiveRecord::Base
|
251
|
-
has_one_attached :avatar
|
192
|
+
has_one_attached :avatar do |attachable|
|
193
|
+
attachable.variant :thumb, resize: "100x100"
|
194
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
195
|
+
end
|
252
196
|
end
|
253
197
|
|
254
198
|
class Gallery < ActiveRecord::Base
|
255
|
-
has_many_attached :photos
|
199
|
+
has_many_attached :photos do |attachable|
|
200
|
+
attachable.variant :thumb, resize: "100x100"
|
201
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
202
|
+
end
|
256
203
|
end
|
257
|
-
```
|
258
|
-
|
259
|
-
*Dmitry Tsepelev*
|
260
|
-
|
261
|
-
* You can optionally provide a custom blob key when attaching a new file:
|
262
|
-
|
263
|
-
```ruby
|
264
|
-
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
265
|
-
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
266
|
-
```
|
267
|
-
|
268
|
-
Active Storage will store the blob's data on the configured service at the provided key.
|
269
204
|
|
270
|
-
|
271
|
-
|
272
|
-
* Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
|
273
|
-
|
274
|
-
`create_after_upload!` has been removed since it could lead to data
|
275
|
-
corruption by uploading to a key on the storage service which happened to
|
276
|
-
be already taken. Creating the record would then correctly raise a
|
277
|
-
database uniqueness exception but the stored object would already have
|
278
|
-
overwritten another. `create_and_upload!` swaps the order of operations
|
279
|
-
so that the key gets reserved up-front or the uniqueness error gets raised,
|
280
|
-
before the upload to a key takes place.
|
281
|
-
|
282
|
-
*Julik Tarkhanov*
|
283
|
-
|
284
|
-
* Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
|
285
|
-
|
286
|
-
*Peter Zhu*
|
287
|
-
|
288
|
-
* Allow record to be optionally passed to blob finders to make sharding
|
289
|
-
easier.
|
290
|
-
|
291
|
-
*Gannon McGibbon*
|
292
|
-
|
293
|
-
* Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
|
294
|
-
|
295
|
-
*Peter Zhu*
|
296
|
-
|
297
|
-
* Add `config.active_storage.draw_routes` to disable Active Storage routes.
|
298
|
-
|
299
|
-
*Gannon McGibbon*
|
300
|
-
|
301
|
-
* Image analysis is skipped if ImageMagick returns an error.
|
302
|
-
|
303
|
-
`ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
|
304
|
-
`MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
|
305
|
-
failures. It now logs the error and returns `{}`, resulting in no metadata
|
306
|
-
being added to the offending image blob.
|
307
|
-
|
308
|
-
*George Claghorn*
|
309
|
-
|
310
|
-
* Method calls on singular attachments return `nil` when no file is attached.
|
311
|
-
|
312
|
-
Previously, assuming the following User model, `user.avatar.filename` would
|
313
|
-
raise a `Module::DelegationError` if no avatar was attached:
|
314
|
-
|
315
|
-
```ruby
|
316
|
-
class User < ApplicationRecord
|
317
|
-
has_one_attached :avatar
|
318
|
-
end
|
205
|
+
<%= image_tag user.avatar.variant(:thumb) %>
|
319
206
|
```
|
320
207
|
|
321
|
-
|
322
|
-
|
323
|
-
*Matthew Tanous*
|
324
|
-
|
325
|
-
* The mirror service supports direct uploads.
|
208
|
+
*fatkodima*
|
326
209
|
|
327
|
-
|
328
|
-
|
329
|
-
to copy it to each secondary service.
|
210
|
+
* After setting `config.active_storage.resolve_model_to_route = :rails_storage_proxy`
|
211
|
+
`rails_blob_path` and `rails_representation_path` will generate proxy URLs by default.
|
330
212
|
|
331
|
-
|
332
|
-
`config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
|
213
|
+
*Ali Ismayilov*
|
333
214
|
|
334
|
-
|
335
|
-
|
336
|
-
* The S3 service now permits uploading files larger than 5 gigabytes.
|
337
|
-
|
338
|
-
When uploading a file greater than 100 megabytes in size, the service
|
339
|
-
transparently switches to [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
|
340
|
-
using a part size computed from the file's total size and S3's part count limit.
|
341
|
-
|
342
|
-
No application changes are necessary to take advantage of this feature. You
|
343
|
-
can customize the default 100 MB multipart upload threshold in your S3
|
344
|
-
service's configuration:
|
345
|
-
|
346
|
-
```yaml
|
347
|
-
production:
|
348
|
-
service: s3
|
349
|
-
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
350
|
-
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
351
|
-
region: us-east-1
|
352
|
-
bucket: my-bucket
|
353
|
-
upload:
|
354
|
-
multipart_threshold: <%= 250.megabytes %>
|
355
|
-
```
|
215
|
+
* Declare `ActiveStorage::FixtureSet` and `ActiveStorage::FixtureSet.blob` to
|
216
|
+
improve fixture integration.
|
356
217
|
|
357
|
-
*
|
218
|
+
*Sean Doyle*
|
358
219
|
|
359
220
|
|
360
|
-
Please check [6-
|
221
|
+
Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activestorage/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
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
|