activestorage 6.1.3.2 → 7.0.0.alpha2
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 +132 -182
- 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 +18 -0
- data/app/controllers/active_storage/representations/proxy_controller.rb +7 -11
- data/app/controllers/active_storage/representations/redirect_controller.rb +7 -7
- 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 +36 -3
- data/app/models/active_storage/blob/representable.rb +8 -6
- data/app/models/active_storage/blob.rb +27 -28
- 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 +4 -7
- data/app/models/active_storage/variant_record.rb +2 -0
- data/app/models/active_storage/variant_with_record.rb +10 -6
- data/app/models/active_storage/variation.rb +2 -2
- 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 +29 -1
- data/lib/active_storage/errors.rb +3 -0
- 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 +1 -1
- data/lib/active_storage/previewer.rb +14 -5
- 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 -1
- data/lib/active_storage/transformers/transformer.rb +1 -1
- data/lib/active_storage.rb +5 -1
- data/lib/tasks/activestorage.rake +5 -1
- metadata +35 -25
- 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: 3b4ee316f0d82476667278f6a01db29789d34942e1d0bf731fe747931e026289
|
4
|
+
data.tar.gz: e29835ba8739a80e1c6a07ef765cad05cb140fd63d29d79a176788cca8a0180f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27e7c48eb5badb4f6676a97bbc4b40d6041d9195de3619a4ffdbfeb149c73946b8beeeadf4782aa41be0fe675d015172fde15220f4dd2866535b38163501a50a
|
7
|
+
data.tar.gz: 66a220e052991ed37729c9c40b49769178e342fa5e0e89640ecc8f5640502f6667742f4ace105fb827a3ea67a0958bbf65433030e4a750adaef119f5962fe285
|
data/CHANGELOG.md
CHANGED
@@ -1,276 +1,226 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 7.0.0.alpha2 (September 15, 2021) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 7.0.0.alpha1 (September 15, 2021) ##
|
7
7
|
|
8
|
-
*
|
9
|
-
mime types data.
|
8
|
+
* Emit Active Support instrumentation events from Active Storage analyzers.
|
10
9
|
|
11
|
-
|
10
|
+
Fixes #42930
|
12
11
|
|
12
|
+
*Shouichi Kamiya*
|
13
13
|
|
14
|
-
|
14
|
+
* Add support for byte range requests
|
15
15
|
|
16
|
-
*
|
16
|
+
*Tom Prats*
|
17
17
|
|
18
|
+
* Attachments can be deleted after their association is no longer defined.
|
18
19
|
|
19
|
-
|
20
|
+
Fixes #42514
|
20
21
|
|
21
|
-
*
|
22
|
+
*Don Sisco*
|
22
23
|
|
24
|
+
* Make `vips` the default variant processor for new apps.
|
23
25
|
|
24
|
-
|
26
|
+
See the upgrade guide for instructions on converting from `mini_magick` to `vips`. `mini_magick` is
|
27
|
+
not deprecated, existing apps can keep using it.
|
25
28
|
|
26
|
-
*
|
29
|
+
*Breno Gazzola*
|
27
30
|
|
31
|
+
* Deprecate `ActiveStorage::Current.host` in favor of `ActiveStorage::Current.url_options` which accepts
|
32
|
+
a host, protocol and port.
|
28
33
|
|
29
|
-
|
34
|
+
*Santiago Bartesaghi*
|
30
35
|
|
31
|
-
*
|
36
|
+
* Allow using [IAM](https://cloud.google.com/storage/docs/access-control/signed-urls) when signing URLs with GCS.
|
32
37
|
|
33
|
-
|
38
|
+
```yaml
|
39
|
+
gcs:
|
40
|
+
service: GCS
|
41
|
+
...
|
42
|
+
iam: true
|
43
|
+
```
|
34
44
|
|
45
|
+
*RRethy*
|
35
46
|
|
36
|
-
|
47
|
+
* OpenSSL constants are now used for Digest computations.
|
37
48
|
|
38
|
-
*
|
39
|
-
purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).
|
49
|
+
*Dirkjan Bussink*
|
40
50
|
|
41
|
-
|
51
|
+
* Deprecate `config.active_storage.replace_on_assign_to_many`. Future versions of Rails
|
52
|
+
will behave the same way as when the config is set to `true`.
|
42
53
|
|
43
|
-
*
|
54
|
+
*Santiago Bartesaghi*
|
44
55
|
|
45
|
-
|
56
|
+
* Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
|
57
|
+
and `service_url` in favor of `url`.
|
46
58
|
|
47
|
-
*
|
59
|
+
*Santiago Bartesaghi*
|
48
60
|
|
49
|
-
|
61
|
+
* Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
|
50
62
|
|
51
|
-
*
|
63
|
+
*Anton Topchii*, *Andrew White*
|
52
64
|
|
53
|
-
|
65
|
+
* Allow to detach an attachment when record is not persisted.
|
54
66
|
|
55
|
-
*
|
67
|
+
*Jacopo Beschi*
|
56
68
|
|
57
|
-
|
69
|
+
* Use libvips instead of ImageMagick to analyze images when `active_storage.variant_processor = vips`.
|
58
70
|
|
59
|
-
*
|
71
|
+
*Breno Gazzola*
|
60
72
|
|
61
|
-
|
73
|
+
* Add metadata value for presence of video channel in video blobs.
|
62
74
|
|
63
|
-
|
75
|
+
The `metadata` attribute of video blobs has a new boolean key named `video` that is set to
|
76
|
+
`true` if the file has an video channel and `false` if it doesn't.
|
64
77
|
|
65
|
-
*
|
78
|
+
*Breno Gazzola*
|
66
79
|
|
67
|
-
*
|
68
|
-
document's crop box rather than its media box, hiding print margins. This
|
69
|
-
matches the behavior of the MuPDF previewer.
|
80
|
+
* Deprecate usage of `purge` and `purge_later` from the association extension.
|
70
81
|
|
71
|
-
*
|
82
|
+
*Jacopo Beschi*
|
72
83
|
|
73
|
-
*
|
84
|
+
* Passing extra parameters in `ActiveStorage::Blob#url` to S3 Client.
|
74
85
|
|
75
|
-
|
86
|
+
This allows calls of `ActiveStorage::Blob#url` to have more interaction with
|
87
|
+
the S3 Presigner, enabling, amongst other options, custom S3 domain URL
|
88
|
+
Generation.
|
76
89
|
|
77
|
-
|
78
|
-
|
79
|
-
`rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
|
90
|
+
```ruby
|
91
|
+
blob = ActiveStorage::Blob.last
|
80
92
|
|
81
|
-
|
82
|
-
|
93
|
+
blob.url # => https://<bucket-name>.s3.<region>.amazonaws.com/<key>
|
94
|
+
blob.url(virtual_host: true) # => # => https://<bucket-name>/<key>
|
83
95
|
```
|
84
96
|
|
85
|
-
|
97
|
+
*josegomezr*
|
86
98
|
|
87
|
-
|
88
|
-
# Proxy attached files instead.
|
89
|
-
config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
90
|
-
```
|
99
|
+
* Allow setting a `Cache-Control` on files uploaded to GCS.
|
91
100
|
|
92
|
-
```
|
93
|
-
|
101
|
+
```yaml
|
102
|
+
gcs:
|
103
|
+
service: GCS
|
104
|
+
...
|
105
|
+
cache_control: "public, max-age=3600"
|
94
106
|
```
|
95
107
|
|
96
|
-
|
97
|
-
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
108
|
+
*maleblond*
|
98
109
|
|
99
|
-
|
100
|
-
|
101
|
-
```
|
110
|
+
* The parameters sent to `ffmpeg` for generating a video preview image are now
|
111
|
+
configurable under `config.active_storage.video_preview_arguments`.
|
102
112
|
|
103
|
-
*
|
113
|
+
*Brendon Muir*
|
104
114
|
|
105
|
-
*
|
106
|
-
|
107
|
-
|
115
|
+
* The ActiveStorage video previewer will now use scene change detection to generate
|
116
|
+
better preview images (rather than the previous default of using the first frame
|
117
|
+
of the video). This change requires FFmpeg v3.4+.
|
108
118
|
|
109
|
-
*
|
119
|
+
*Jonathan Hefner*
|
110
120
|
|
111
|
-
* Add support for
|
121
|
+
* Add support for ActiveStorage expiring URLs.
|
112
122
|
|
113
|
-
|
123
|
+
```ruby
|
124
|
+
rails_blob_path(user.avatar, disposition: "attachment", expires_in: 30.minutes)
|
114
125
|
|
115
|
-
|
126
|
+
<%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_in: 30.minutes) %>
|
127
|
+
```
|
116
128
|
|
117
|
-
|
129
|
+
If you want to set default expiration time for ActiveStorage URLs throughout your application, set `config.active_storage.urls_expire_in`.
|
118
130
|
|
119
|
-
*
|
131
|
+
*aki77*
|
120
132
|
|
121
|
-
|
133
|
+
* Allow to purge an attachment when record is not persisted for `has_many_attached`.
|
122
134
|
|
123
|
-
*
|
135
|
+
*Jacopo Beschi*
|
124
136
|
|
125
|
-
|
137
|
+
* Add `with_all_variant_records` method to eager load all variant records on an attachment at once.
|
138
|
+
`with_attached_image` scope now eager loads variant records if using variant tracking.
|
126
139
|
|
127
|
-
*
|
140
|
+
*Alex Ghiculescu*
|
128
141
|
|
129
|
-
|
130
|
-
`service_name` field in the generated URL in `DiskService`.
|
142
|
+
* Add metadata value for presence of audio channel in video blobs.
|
131
143
|
|
132
|
-
|
144
|
+
The `metadata` attribute of video blobs has a new boolean key named `audio` that is set to
|
145
|
+
`true` if the file has an audio channel and `false` if it doesn't.
|
133
146
|
|
134
|
-
*
|
147
|
+
*Breno Gazzola*
|
135
148
|
|
136
|
-
|
149
|
+
* Adds analyzer for audio files.
|
137
150
|
|
138
|
-
*
|
151
|
+
*Breno Gazzola*
|
139
152
|
|
140
|
-
|
141
|
-
`#url` method to be consistent with `Blob`.
|
153
|
+
* Respect Active Record's primary_key_type in Active Storage migrations.
|
142
154
|
|
143
|
-
*
|
155
|
+
*fatkodima*
|
144
156
|
|
145
|
-
*
|
157
|
+
* Allow `expires_in` for ActiveStorage signed ids.
|
146
158
|
|
147
|
-
|
148
|
-
`public: true | false` to indicate whether a service holds public
|
149
|
-
blobs or private blobs. Public services will always return a permanent URL.
|
159
|
+
*aki77*
|
150
160
|
|
151
|
-
|
161
|
+
* Allow to purge an attachment when record is not persisted for `has_one_attached`.
|
152
162
|
|
153
|
-
*
|
163
|
+
*Jacopo Beschi*
|
154
164
|
|
155
|
-
*
|
165
|
+
* Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
|
166
|
+
to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
|
167
|
+
`ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
|
168
|
+
that already have load hooks.
|
156
169
|
|
157
|
-
*
|
170
|
+
*Brendon Muir*
|
158
171
|
|
159
|
-
*
|
172
|
+
* `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
|
160
173
|
|
161
|
-
*
|
174
|
+
*Alex Robbin*
|
162
175
|
|
163
|
-
*
|
176
|
+
* Add `ActiveStorage::Streaming` module that can be included in a controller to get access to `#send_blob_stream`,
|
177
|
+
which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
|
164
178
|
|
165
179
|
```ruby
|
166
|
-
class
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
180
|
+
class MyPublicBlobsController < ApplicationController
|
181
|
+
include ActiveStorage::SetBlob, ActiveStorage::Streaming
|
182
|
+
|
183
|
+
def show
|
184
|
+
http_cache_forever(public: true) do
|
185
|
+
send_blob_stream @blob, disposition: params[:disposition]
|
186
|
+
end
|
187
|
+
end
|
172
188
|
end
|
173
189
|
```
|
174
190
|
|
175
|
-
*
|
176
|
-
|
177
|
-
* You can optionally provide a custom blob key when attaching a new file:
|
178
|
-
|
179
|
-
```ruby
|
180
|
-
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
181
|
-
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
182
|
-
```
|
183
|
-
|
184
|
-
Active Storage will store the blob's data on the configured service at the provided key.
|
185
|
-
|
186
|
-
*George Claghorn*
|
187
|
-
|
188
|
-
* Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
|
189
|
-
|
190
|
-
`create_after_upload!` has been removed since it could lead to data
|
191
|
-
corruption by uploading to a key on the storage service which happened to
|
192
|
-
be already taken. Creating the record would then correctly raise a
|
193
|
-
database uniqueness exception but the stored object would already have
|
194
|
-
overwritten another. `create_and_upload!` swaps the order of operations
|
195
|
-
so that the key gets reserved up-front or the uniqueness error gets raised,
|
196
|
-
before the upload to a key takes place.
|
191
|
+
*DHH*
|
197
192
|
|
198
|
-
|
199
|
-
|
200
|
-
* Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
|
201
|
-
|
202
|
-
*Peter Zhu*
|
203
|
-
|
204
|
-
* Allow record to be optionally passed to blob finders to make sharding
|
205
|
-
easier.
|
206
|
-
|
207
|
-
*Gannon McGibbon*
|
208
|
-
|
209
|
-
* Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
|
210
|
-
|
211
|
-
*Peter Zhu*
|
212
|
-
|
213
|
-
* Add `config.active_storage.draw_routes` to disable Active Storage routes.
|
214
|
-
|
215
|
-
*Gannon McGibbon*
|
216
|
-
|
217
|
-
* Image analysis is skipped if ImageMagick returns an error.
|
218
|
-
|
219
|
-
`ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
|
220
|
-
`MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
|
221
|
-
failures. It now logs the error and returns `{}`, resulting in no metadata
|
222
|
-
being added to the offending image blob.
|
223
|
-
|
224
|
-
*George Claghorn*
|
225
|
-
|
226
|
-
* Method calls on singular attachments return `nil` when no file is attached.
|
227
|
-
|
228
|
-
Previously, assuming the following User model, `user.avatar.filename` would
|
229
|
-
raise a `Module::DelegationError` if no avatar was attached:
|
193
|
+
* Add ability to use pre-defined variants.
|
230
194
|
|
231
195
|
```ruby
|
232
|
-
class User <
|
233
|
-
has_one_attached :avatar
|
196
|
+
class User < ActiveRecord::Base
|
197
|
+
has_one_attached :avatar do |attachable|
|
198
|
+
attachable.variant :thumb, resize: "100x100"
|
199
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
200
|
+
end
|
234
201
|
end
|
235
|
-
```
|
236
|
-
|
237
|
-
They now return `nil`.
|
238
|
-
|
239
|
-
*Matthew Tanous*
|
240
|
-
|
241
|
-
* The mirror service supports direct uploads.
|
242
202
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
203
|
+
class Gallery < ActiveRecord::Base
|
204
|
+
has_many_attached :photos do |attachable|
|
205
|
+
attachable.variant :thumb, resize: "100x100"
|
206
|
+
attachable.variant :medium, resize: "300x300", monochrome: true
|
207
|
+
end
|
208
|
+
end
|
249
209
|
|
250
|
-
|
210
|
+
<%= image_tag user.avatar.variant(:thumb) %>
|
211
|
+
```
|
251
212
|
|
252
|
-
*
|
213
|
+
*fatkodima*
|
253
214
|
|
254
|
-
|
255
|
-
|
256
|
-
using a part size computed from the file's total size and S3's part count limit.
|
215
|
+
* After setting `config.active_storage.resolve_model_to_route = :rails_storage_proxy`
|
216
|
+
`rails_blob_path` and `rails_representation_path` will generate proxy URLs by default.
|
257
217
|
|
258
|
-
|
259
|
-
can customize the default 100 MB multipart upload threshold in your S3
|
260
|
-
service's configuration:
|
218
|
+
*Ali Ismayilov*
|
261
219
|
|
262
|
-
|
263
|
-
|
264
|
-
service: s3
|
265
|
-
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
266
|
-
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
267
|
-
region: us-east-1
|
268
|
-
bucket: my-bucket
|
269
|
-
upload:
|
270
|
-
multipart_threshold: <%= 250.megabytes %>
|
271
|
-
```
|
220
|
+
* Declare `ActiveStorage::FixtureSet` and `ActiveStorage::FixtureSet.blob` to
|
221
|
+
improve fixture integration.
|
272
222
|
|
273
|
-
*
|
223
|
+
*Sean Doyle*
|
274
224
|
|
275
225
|
|
276
|
-
Please check [6-
|
226
|
+
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
|