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