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