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