activestorage 6.0.3.4 → 6.1.0.rc1
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 +144 -162
- 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/disk_controller.rb +8 -20
- data/app/controllers/active_storage/representations/proxy_controller.rb +19 -0
- data/app/controllers/active_storage/{representations_controller.rb → representations/redirect_controller.rb} +2 -2
- 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 +18 -10
- data/app/models/active_storage/blob.rb +114 -59
- 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/preview.rb +31 -10
- data/app/models/active_storage/record.rb +7 -0
- data/app/models/active_storage/variant.rb +28 -41
- 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 +25 -20
- data/config/routes.rb +58 -8
- data/db/migrate/20170806125915_create_active_storage_tables.rb +14 -5
- data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +17 -0
- data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +11 -0
- data/lib/active_storage.rb +5 -2
- data/lib/active_storage/analyzer.rb +6 -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/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 +59 -12
- data/lib/active_storage/attached/one.rb +4 -3
- data/lib/active_storage/engine.rb +25 -27
- data/lib/active_storage/gem_version.rb +3 -3
- data/lib/active_storage/log_subscriber.rb +6 -0
- data/lib/active_storage/previewer.rb +3 -2
- data/lib/active_storage/previewer/mupdf_previewer.rb +3 -3
- data/lib/active_storage/previewer/poppler_pdf_previewer.rb +3 -3
- data/lib/active_storage/previewer/video_previewer.rb +2 -2
- data/lib/active_storage/service.rb +36 -7
- 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 +53 -23
- data/lib/active_storage/transformers/image_processing_transformer.rb +13 -7
- data/lib/active_storage/transformers/transformer.rb +0 -3
- metadata +57 -21
- 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: 2b5828c669886bb3073bc9a325644f70785b9e7432fe34bf609369ae854472d1
|
4
|
+
data.tar.gz: c20c99725925af7c67f86c4ad99fcc5add79a4c373db3c1d5ae6fe4c2b1a893b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0adc41784932bd392d92f120fadea916633ccf659a2b2d5d3b6a305eee2ca093a6d82045e322b40a5d6349cfeae880db08c87f1972bb40e954f52dd1457c45
|
7
|
+
data.tar.gz: adf193c0617237b63aaf251b0e0fe8ec0e48da5b3dc47d8a6e60a5b91ea976d3a205dd990a0a2b20d65bd21b70dc5eccbaed0a512a86c03445be84811fa5deda
|
data/CHANGELOG.md
CHANGED
@@ -1,250 +1,232 @@
|
|
1
|
-
## Rails 6.0.
|
1
|
+
## Rails 6.1.0.rc1 (November 02, 2020) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`.
|
4
4
|
|
5
|
+
*Rafael Mendonça França*
|
5
6
|
|
6
|
-
|
7
|
+
* Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer`.
|
7
8
|
|
8
|
-
*
|
9
|
+
*Rafael Mendonça França*
|
9
10
|
|
11
|
+
* Remove deprecated `config.active_storage.queue`.
|
10
12
|
|
11
|
-
|
13
|
+
*Rafael Mendonça França*
|
12
14
|
|
13
|
-
*
|
15
|
+
* Remove deprecated `ActiveStorage::Downloading`.
|
14
16
|
|
17
|
+
*Rafael Mendonça França*
|
15
18
|
|
16
|
-
|
19
|
+
* Add per-environment configuration support
|
17
20
|
|
18
|
-
*
|
21
|
+
*Pietro Moro*
|
19
22
|
|
20
|
-
|
23
|
+
* The Poppler PDF previewer renders a preview image using the original
|
24
|
+
document's crop box rather than its media box, hiding print margins. This
|
25
|
+
matches the behavior of the MuPDF previewer.
|
21
26
|
|
22
|
-
*
|
27
|
+
*Vincent Robert*
|
23
28
|
|
29
|
+
* Touch parent model when an attachment is purged.
|
24
30
|
|
25
|
-
|
31
|
+
*Víctor Pérez Rodríguez*
|
26
32
|
|
27
|
-
*
|
33
|
+
* Files can now be served by proxying them from the underlying storage service
|
34
|
+
instead of redirecting to a signed service URL. Use the
|
35
|
+
`rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
|
28
36
|
|
37
|
+
```erb
|
38
|
+
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
39
|
+
```
|
29
40
|
|
30
|
-
|
31
|
-
|
32
|
-
* No changes.
|
33
|
-
|
34
|
-
|
35
|
-
## Rails 6.0.2 (December 13, 2019) ##
|
36
|
-
|
37
|
-
* No changes.
|
38
|
-
|
39
|
-
|
40
|
-
## Rails 6.0.1 (November 5, 2019) ##
|
41
|
-
|
42
|
-
* `ActiveStorage::AnalyzeJob`s are discarded on `ActiveRecord::RecordNotFound` errors.
|
43
|
-
|
44
|
-
*George Claghorn*
|
45
|
-
|
46
|
-
* Blobs are recorded in the database before being uploaded to the service.
|
47
|
-
This fixes that generated blob keys could silently collide, leading to
|
48
|
-
data loss.
|
49
|
-
|
50
|
-
*Julik Tarkhanov*
|
51
|
-
|
41
|
+
To proxy by default, set `config.active_storage.resolve_model_to_route`:
|
52
42
|
|
53
|
-
|
43
|
+
```ruby
|
44
|
+
# Proxy attached files instead.
|
45
|
+
config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
46
|
+
```
|
54
47
|
|
55
|
-
|
48
|
+
```erb
|
49
|
+
<%= image_tag @user.avatar %>
|
50
|
+
```
|
56
51
|
|
52
|
+
To redirect to a signed service URL when the default file serving strategy
|
53
|
+
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
57
54
|
|
58
|
-
|
55
|
+
```erb
|
56
|
+
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
57
|
+
```
|
59
58
|
|
60
|
-
*
|
59
|
+
*Jonathan Fleckenstein*
|
61
60
|
|
61
|
+
* Add `config.active_storage.web_image_content_types` to allow applications
|
62
|
+
to add content types (like `image/webp`) in which variants can be processed,
|
63
|
+
instead of letting those images be converted to the fallback PNG format.
|
62
64
|
|
63
|
-
|
65
|
+
*Jeroen van Haperen*
|
64
66
|
|
65
|
-
*
|
67
|
+
* Add support for creating variants of `WebP` images out of the box.
|
66
68
|
|
67
|
-
|
69
|
+
*Dino Maric*
|
68
70
|
|
69
|
-
|
71
|
+
* Only enqueue analysis jobs for blobs with non-null analyzer classes.
|
70
72
|
|
71
|
-
*
|
73
|
+
*Gannon McGibbon*
|
72
74
|
|
73
|
-
|
75
|
+
* Previews are created on the same service as the original blob.
|
74
76
|
|
77
|
+
*Peter Zhu*
|
75
78
|
|
76
|
-
|
79
|
+
* Remove unused `disposition` and `content_type` query parameters for `DiskService`.
|
77
80
|
|
78
|
-
*
|
81
|
+
*Peter Zhu*
|
79
82
|
|
83
|
+
* Use `DiskController` for both public and private files.
|
80
84
|
|
81
|
-
|
85
|
+
`DiskController` is able to handle multiple services by adding a
|
86
|
+
`service_name` field in the generated URL in `DiskService`.
|
82
87
|
|
83
|
-
*
|
88
|
+
*Peter Zhu*
|
84
89
|
|
90
|
+
* Variants are tracked in the database to avoid existence checks in the storage service.
|
85
91
|
|
86
|
-
|
92
|
+
*George Claghorn*
|
87
93
|
|
88
|
-
*
|
89
|
-
[`activestorage`](https://www.npmjs.com/package/activestorage) to
|
90
|
-
[`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
|
94
|
+
* Deprecate `service_url` methods in favour of `url`.
|
91
95
|
|
92
|
-
|
96
|
+
Deprecate `Variant#service_url` and `Preview#service_url` to instead use
|
97
|
+
`#url` method to be consistent with `Blob`.
|
93
98
|
|
94
|
-
*
|
95
|
-
queues analysis and purge jobs should use, respectively:
|
99
|
+
*Peter Zhu*
|
96
100
|
|
97
|
-
|
98
|
-
* `config.active_storage.queues.purge`
|
101
|
+
* Permanent URLs for public storage blobs.
|
99
102
|
|
100
|
-
`config.
|
101
|
-
|
103
|
+
Services can be configured in `config/storage.yml` with a new key
|
104
|
+
`public: true | false` to indicate whether a service holds public
|
105
|
+
blobs or private blobs. Public services will always return a permanent URL.
|
102
106
|
|
103
|
-
|
107
|
+
Deprecates `Blob#service_url` in favor of `Blob#url`.
|
104
108
|
|
105
|
-
*
|
109
|
+
*Peter Zhu*
|
106
110
|
|
107
|
-
|
111
|
+
* Make services aware of configuration names.
|
108
112
|
|
109
|
-
*
|
110
|
-
collisions and undefined behavior with case-insensitive filesystems and
|
111
|
-
database indices.
|
113
|
+
*Gannon McGibbon*
|
112
114
|
|
113
|
-
|
115
|
+
* The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.
|
114
116
|
|
115
|
-
*
|
116
|
-
the page. It previously included one with a value of `undefined`.
|
117
|
+
*Kyle Ribordy*
|
117
118
|
|
118
|
-
|
119
|
+
* Allow storage services to be configured per attachment.
|
119
120
|
|
120
|
-
|
121
|
+
```ruby
|
122
|
+
class User < ActiveRecord::Base
|
123
|
+
has_one_attached :avatar, service: :s3
|
124
|
+
end
|
121
125
|
|
122
|
-
|
126
|
+
class Gallery < ActiveRecord::Base
|
127
|
+
has_many_attached :photos, service: :s3
|
128
|
+
end
|
129
|
+
```
|
123
130
|
|
124
|
-
*
|
131
|
+
*Dmitry Tsepelev*
|
125
132
|
|
126
|
-
|
133
|
+
* You can optionally provide a custom blob key when attaching a new file:
|
127
134
|
|
128
|
-
|
135
|
+
```ruby
|
136
|
+
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
137
|
+
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
138
|
+
```
|
129
139
|
|
130
|
-
|
140
|
+
Active Storage will store the blob's data on the configured service at the provided key.
|
131
141
|
|
132
|
-
*
|
133
|
-
relevant types of `Azure::Core::Http::HTTPError`. It previously obscured
|
134
|
-
other types of `HTTPError`, which is the azure-storage gem’s catch-all
|
135
|
-
exception class.
|
142
|
+
*George Claghorn*
|
136
143
|
|
137
|
-
|
144
|
+
* Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
|
138
145
|
|
139
|
-
|
140
|
-
|
141
|
-
|
146
|
+
`create_after_upload!` has been removed since it could lead to data
|
147
|
+
corruption by uploading to a key on the storage service which happened to
|
148
|
+
be already taken. Creating the record would then correctly raise a
|
149
|
+
database uniqueness exception but the stored object would already have
|
150
|
+
overwritten another. `create_and_upload!` swaps the order of operations
|
151
|
+
so that the key gets reserved up-front or the uniqueness error gets raised,
|
152
|
+
before the upload to a key takes place.
|
142
153
|
|
143
|
-
*
|
154
|
+
*Julik Tarkhanov*
|
144
155
|
|
145
|
-
* `
|
146
|
-
`ActiveStorage::FileNotFoundError` when the corresponding file is missing
|
147
|
-
from the storage service. Services translate service-specific missing object
|
148
|
-
exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and
|
149
|
-
`Errno::ENOENT` for the disk service) into
|
150
|
-
`ActiveStorage::FileNotFoundError`.
|
156
|
+
* Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
|
151
157
|
|
152
|
-
*
|
158
|
+
*Peter Zhu*
|
153
159
|
|
154
|
-
*
|
155
|
-
|
160
|
+
* Allow record to be optionally passed to blob finders to make sharding
|
161
|
+
easier.
|
156
162
|
|
157
|
-
*
|
163
|
+
*Gannon McGibbon*
|
158
164
|
|
159
|
-
*
|
160
|
-
`ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
|
161
|
-
instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
|
162
|
-
handle all Active Storage errors.
|
165
|
+
* Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
|
163
166
|
|
164
|
-
*
|
167
|
+
*Peter Zhu*
|
165
168
|
|
166
|
-
*
|
167
|
-
is saved instead of immediately.
|
169
|
+
* Add `config.active_storage.draw_routes` to disable Active Storage routes.
|
168
170
|
|
169
|
-
|
170
|
-
be stored:
|
171
|
+
*Gannon McGibbon*
|
171
172
|
|
172
|
-
|
173
|
-
@user.avatar = params[:avatar]
|
174
|
-
```
|
173
|
+
* Image analysis is skipped if ImageMagick returns an error.
|
175
174
|
|
176
|
-
|
175
|
+
`ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
|
176
|
+
`MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
|
177
|
+
failures. It now logs the error and returns `{}`, resulting in no metadata
|
178
|
+
being added to the offending image blob.
|
177
179
|
|
178
180
|
*George Claghorn*
|
179
181
|
|
180
|
-
*
|
181
|
-
ActiveRecord reflection mechanism.
|
182
|
-
|
183
|
-
*Kevin Deisz*
|
182
|
+
* Method calls on singular attachments return `nil` when no file is attached.
|
184
183
|
|
185
|
-
|
186
|
-
|
187
|
-
variation applied:
|
184
|
+
Previously, assuming the following User model, `user.avatar.filename` would
|
185
|
+
raise a `Module::DelegationError` if no avatar was attached:
|
188
186
|
|
189
187
|
```ruby
|
190
|
-
|
188
|
+
class User < ApplicationRecord
|
189
|
+
has_one_attached :avatar
|
190
|
+
end
|
191
191
|
```
|
192
192
|
|
193
|
-
|
193
|
+
They now return `nil`.
|
194
194
|
|
195
|
-
*
|
196
|
-
within the model's `GeneratedAssociationMethods` module to
|
197
|
-
allow overriding and composition using `super`.
|
195
|
+
*Matthew Tanous*
|
198
196
|
|
199
|
-
|
197
|
+
* The mirror service supports direct uploads.
|
200
198
|
|
201
|
-
|
202
|
-
|
199
|
+
New files are directly uploaded to the primary service. When a
|
200
|
+
directly-uploaded file is attached to a record, a background job is enqueued
|
201
|
+
to copy it to each secondary service.
|
203
202
|
|
204
|
-
|
203
|
+
Configure the queue used to process mirroring jobs by setting
|
204
|
+
`config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
|
205
205
|
|
206
|
-
*
|
207
|
-
`ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
|
208
|
-
type inference. For example:
|
206
|
+
*George Claghorn*
|
209
207
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
208
|
+
* The S3 service now permits uploading files larger than 5 gigabytes.
|
209
|
+
|
210
|
+
When uploading a file greater than 100 megabytes in size, the service
|
211
|
+
transparently switches to [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
|
212
|
+
using a part size computed from the file's total size and S3's part count limit.
|
213
|
+
|
214
|
+
No application changes are necessary to take advantage of this feature. You
|
215
|
+
can customize the default 100 MB multipart upload threshold in your S3
|
216
|
+
service's configuration:
|
217
|
+
|
218
|
+
```yaml
|
219
|
+
production:
|
220
|
+
service: s3
|
221
|
+
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
222
|
+
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
223
|
+
region: us-east-1
|
224
|
+
bucket: my-bucket
|
225
|
+
upload:
|
226
|
+
multipart_threshold: <%= 250.megabytes %>
|
217
227
|
```
|
218
228
|
|
219
|
-
*Ryan Davidson*
|
220
|
-
|
221
|
-
* The Google Cloud Storage service properly supports streaming downloads.
|
222
|
-
It now requires version 1.11 or newer of the google-cloud-storage gem.
|
223
|
-
|
224
229
|
*George Claghorn*
|
225
230
|
|
226
|
-
* Use the [ImageProcessing](https://github.com/janko-m/image_processing) gem
|
227
|
-
for Active Storage variants, and deprecate the MiniMagick backend.
|
228
|
-
|
229
|
-
This means that variants are now automatically oriented if the original
|
230
|
-
image was rotated. Also, in addition to the existing ImageMagick
|
231
|
-
operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
|
232
|
-
other ImageProcessing macros. These are now recommended over raw `:resize`,
|
233
|
-
as they also sharpen the thumbnail after resizing.
|
234
|
-
|
235
|
-
The ImageProcessing gem also comes with a backend implemented on
|
236
|
-
[libvips](http://jcupitt.github.io/libvips/), an alternative to
|
237
|
-
ImageMagick which has significantly better performance than
|
238
|
-
ImageMagick in most cases, both in terms of speed and memory usage. In
|
239
|
-
Active Storage it's now possible to switch to the libvips backend by
|
240
|
-
changing `Rails.application.config.active_storage.variant_processor` to
|
241
|
-
`:vips`.
|
242
|
-
|
243
|
-
*Janko Marohnić*
|
244
|
-
|
245
|
-
* Rails 6 requires Ruby 2.5.0 or newer.
|
246
|
-
|
247
|
-
*Jeremy Daer*, *Kasper Timm Hansen*
|
248
|
-
|
249
231
|
|
250
|
-
Please check [
|
232
|
+
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
|
|