activestorage 6.1.7.2 → 7.0.0.alpha1

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.

Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +126 -291
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +25 -11
  5. data/app/assets/javascripts/activestorage.esm.js +844 -0
  6. data/app/assets/javascripts/activestorage.js +257 -376
  7. data/app/controllers/active_storage/base_controller.rb +1 -10
  8. data/app/controllers/active_storage/blobs/proxy_controller.rb +14 -4
  9. data/app/controllers/active_storage/blobs/redirect_controller.rb +6 -4
  10. data/app/controllers/active_storage/representations/base_controller.rb +5 -1
  11. data/app/controllers/active_storage/representations/proxy_controller.rb +6 -4
  12. data/app/controllers/active_storage/representations/redirect_controller.rb +6 -4
  13. data/app/controllers/concerns/active_storage/set_blob.rb +6 -2
  14. data/app/controllers/concerns/active_storage/set_current.rb +3 -3
  15. data/app/controllers/concerns/active_storage/streaming.rb +65 -0
  16. data/app/javascript/activestorage/ujs.js +1 -1
  17. data/app/models/active_storage/attachment.rb +35 -2
  18. data/app/models/active_storage/blob/representable.rb +7 -5
  19. data/app/models/active_storage/blob.rb +26 -27
  20. data/app/models/active_storage/current.rb +12 -2
  21. data/app/models/active_storage/preview.rb +6 -4
  22. data/app/models/active_storage/record.rb +1 -1
  23. data/app/models/active_storage/variant.rb +6 -9
  24. data/app/models/active_storage/variant_record.rb +2 -0
  25. data/app/models/active_storage/variant_with_record.rb +9 -5
  26. data/app/models/active_storage/variation.rb +3 -3
  27. data/config/routes.rb +10 -10
  28. data/db/migrate/20170806125915_create_active_storage_tables.rb +11 -2
  29. data/db/update_migrate/20190112182829_add_service_name_to_active_storage_blobs.rb +0 -4
  30. data/db/update_migrate/20191206030411_create_active_storage_variant_records.rb +1 -3
  31. data/lib/active_storage/analyzer/audio_analyzer.rb +65 -0
  32. data/lib/active_storage/analyzer/image_analyzer/image_magick.rb +39 -0
  33. data/lib/active_storage/analyzer/image_analyzer/vips.rb +49 -0
  34. data/lib/active_storage/analyzer/image_analyzer.rb +2 -30
  35. data/lib/active_storage/analyzer/video_analyzer.rb +26 -11
  36. data/lib/active_storage/analyzer.rb +8 -4
  37. data/lib/active_storage/attached/changes/create_many.rb +7 -3
  38. data/lib/active_storage/attached/changes/create_one.rb +1 -1
  39. data/lib/active_storage/attached/changes/create_one_of_many.rb +1 -1
  40. data/lib/active_storage/attached/changes/delete_many.rb +1 -1
  41. data/lib/active_storage/attached/changes/delete_one.rb +1 -1
  42. data/lib/active_storage/attached/changes/detach_many.rb +18 -0
  43. data/lib/active_storage/attached/changes/detach_one.rb +24 -0
  44. data/lib/active_storage/attached/changes/purge_many.rb +27 -0
  45. data/lib/active_storage/attached/changes/purge_one.rb +27 -0
  46. data/lib/active_storage/attached/changes.rb +7 -1
  47. data/lib/active_storage/attached/many.rb +27 -15
  48. data/lib/active_storage/attached/model.rb +31 -5
  49. data/lib/active_storage/attached/one.rb +32 -27
  50. data/lib/active_storage/downloader.rb +2 -2
  51. data/lib/active_storage/engine.rb +28 -16
  52. data/lib/active_storage/fixture_set.rb +76 -0
  53. data/lib/active_storage/gem_version.rb +4 -4
  54. data/lib/active_storage/previewer/video_previewer.rb +0 -2
  55. data/lib/active_storage/previewer.rb +4 -4
  56. data/lib/active_storage/reflection.rb +12 -2
  57. data/lib/active_storage/service/azure_storage_service.rb +1 -1
  58. data/lib/active_storage/service/configurator.rb +1 -1
  59. data/lib/active_storage/service/disk_service.rb +13 -18
  60. data/lib/active_storage/service/gcs_service.rb +91 -7
  61. data/lib/active_storage/service/mirror_service.rb +1 -1
  62. data/lib/active_storage/service/registry.rb +1 -1
  63. data/lib/active_storage/service/s3_service.rb +4 -4
  64. data/lib/active_storage/service.rb +3 -3
  65. data/lib/active_storage/transformers/image_processing_transformer.rb +1 -66
  66. data/lib/active_storage/transformers/transformer.rb +1 -1
  67. data/lib/active_storage.rb +3 -292
  68. metadata +32 -24
  69. 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: 0d98803384f1af3ac972a670ef268d639845a8f4caa922fab3469d3c99aeb6df
4
- data.tar.gz: 2329e1b55b9c31337f1a3f1c5db84c9979eeabe87c79b967fce9c82c79501814
3
+ metadata.gz: c267f362a238a90819d7e7cd23917d10970b03acd2956d099ea6aeb26c2ce192
4
+ data.tar.gz: c669f3a56d9b6f3f5a08e89cfb49725d65d1abf0d7e933c50b6a3fc12c7d9a6d
5
5
  SHA512:
6
- metadata.gz: 14d943929ee9e2766a78837630a943e54ba6d02bc97bcfb17d5d6bca0b0cbc87226b261475baeb1e28aa4b1530fc3312cb1ef64bb416e7fe44f91e11f58b3cee
7
- data.tar.gz: d630c6ac5262055651ab02dd66fb03efcab41a4e3fd98383dc8c9a0faedb143bd38fafc86754702fa836cc002bd25d9146d2de5cfdc2c14833063103685da39d
6
+ metadata.gz: cf96bff832fd497ff5475a475c2b8d5d22b12243d4126bd973ec28c670f9fb57e2e787c073c2ebf4edd89fb3a1d2fbd703a47e0f9a76490389b22e7e9483e2bd
7
+ data.tar.gz: a405ab97196c4b8c60f284b3e7c664ed30756a08abfe2d1f5d50c43630ec5cfd46d71dcd533e545151312f16459aec534a55f533be95aa6ee47021d29ce30466
data/CHANGELOG.md CHANGED
@@ -1,386 +1,221 @@
1
- ## Rails 6.1.7.2 (January 24, 2023) ##
1
+ ## Rails 7.0.0.alpha1 (September 15, 2021) ##
2
2
 
3
- * No changes.
3
+ * Emit Active Support instrumentation events from Active Storage analyzers.
4
4
 
5
+ Fixes #42930
5
6
 
6
- ## Rails 6.1.7.1 (January 17, 2023) ##
7
+ *Shouichi Kamiya*
7
8
 
8
- * No changes.
9
+ * Add support for byte range requests
9
10
 
11
+ *Tom Prats*
10
12
 
11
- ## Rails 6.1.7 (September 09, 2022) ##
12
-
13
- * Respect Active Record's primary_key_type in Active Storage migrations. Backported from 7.0.
14
-
15
- *fatkodima*
16
-
17
- ## Rails 6.1.6.1 (July 12, 2022) ##
13
+ * Attachments can be deleted after their association is no longer defined.
18
14
 
19
- * No changes.
15
+ Fixes #42514
20
16
 
17
+ *Don Sisco*
21
18
 
22
- ## Rails 6.1.6 (May 09, 2022) ##
19
+ * Make `vips` the default variant processor for new apps.
23
20
 
24
- * No changes.
21
+ See the upgrade guide for instructions on converting from `mini_magick` to `vips`. `mini_magick` is
22
+ not deprecated, existing apps can keep using it.
25
23
 
24
+ *Breno Gazzola*
26
25
 
27
- ## Rails 6.1.5.1 (April 26, 2022) ##
26
+ * Deprecate `ActiveStorage::Current.host` in favor of `ActiveStorage::Current.url_options` which accepts
27
+ a host, protocol and port.
28
28
 
29
- * No changes.
29
+ *Santiago Bartesaghi*
30
30
 
31
+ * Allow using [IAM](https://cloud.google.com/storage/docs/access-control/signed-urls) when signing URLs with GCS.
31
32
 
32
- ## Rails 6.1.5 (March 09, 2022) ##
33
+ ```yaml
34
+ gcs:
35
+ service: GCS
36
+ ...
37
+ iam: true
38
+ ```
33
39
 
34
- * Attachments can be deleted after their association is no longer defined.
40
+ *RRethy*
35
41
 
36
- Fixes #42514
42
+ * OpenSSL constants are now used for Digest computations.
37
43
 
38
- *Don Sisco*
44
+ *Dirkjan Bussink*
39
45
 
46
+ * Deprecate `config.active_storage.replace_on_assign_to_many`. Future versions of Rails
47
+ will behave the same way as when the config is set to `true`.
40
48
 
41
- ## Rails 6.1.4.7 (March 08, 2022) ##
49
+ *Santiago Bartesaghi*
42
50
 
43
- * Added image transformation validation via configurable allow-list.
44
-
45
- Variant now offers a configurable allow-list for
46
- transformation methods in addition to a configurable deny-list for arguments.
47
-
48
- [CVE-2022-21831]
51
+ * Remove deprecated methods: `build_after_upload`, `create_after_upload!` in favor of `create_and_upload!`,
52
+ and `service_url` in favor of `url`.
49
53
 
54
+ *Santiago Bartesaghi*
50
55
 
51
- ## Rails 6.1.4.6 (February 11, 2022) ##
56
+ * Add support of `strict_loading_by_default` to `ActiveStorage::Representations` controllers.
52
57
 
53
- * No changes.
58
+ *Anton Topchii*, *Andrew White*
54
59
 
60
+ * Allow to detach an attachment when record is not persisted.
55
61
 
56
- ## Rails 6.1.4.5 (February 11, 2022) ##
62
+ *Jacopo Beschi*
57
63
 
58
- * No changes.
64
+ * Use libvips instead of ImageMagick to analyze images when `active_storage.variant_processor = vips`.
59
65
 
66
+ *Breno Gazzola*
60
67
 
61
- ## Rails 6.1.4.4 (December 15, 2021) ##
68
+ * Add metadata value for presence of video channel in video blobs.
62
69
 
63
- * No changes.
70
+ The `metadata` attribute of video blobs has a new boolean key named `video` that is set to
71
+ `true` if the file has an video channel and `false` if it doesn't.
64
72
 
73
+ *Breno Gazzola*
65
74
 
66
- ## Rails 6.1.4.3 (December 14, 2021) ##
75
+ * Deprecate usage of `purge` and `purge_later` from the association extension.
67
76
 
68
- * No changes.
77
+ *Jacopo Beschi*
69
78
 
79
+ * Passing extra parameters in `ActiveStorage::Blob#url` to S3 Client.
70
80
 
71
- ## Rails 6.1.4.2 (December 14, 2021) ##
81
+ This allows calls of `ActiveStorage::Blob#url` to have more interaction with
82
+ the S3 Presigner, enabling, amongst other options, custom S3 domain URL
83
+ Generation.
72
84
 
73
- * No changes.
85
+ ```ruby
86
+ blob = ActiveStorage::Blob.last
74
87
 
88
+ blob.url # => https://<bucket-name>.s3.<region>.amazonaws.com/<key>
89
+ blob.url(virtual_host: true) # => # => https://<bucket-name>/<key>
90
+ ```
75
91
 
76
- ## Rails 6.1.4.1 (August 19, 2021) ##
92
+ *josegomezr*
77
93
 
78
- * No changes.
94
+ * Allow setting a `Cache-Control` on files uploaded to GCS.
79
95
 
96
+ ```yaml
97
+ gcs:
98
+ service: GCS
99
+ ...
100
+ cache_control: "public, max-age=3600"
101
+ ```
80
102
 
81
- ## Rails 6.1.4 (June 24, 2021) ##
103
+ *maleblond*
82
104
 
83
105
  * The parameters sent to `ffmpeg` for generating a video preview image are now
84
106
  configurable under `config.active_storage.video_preview_arguments`.
85
107
 
86
108
  *Brendon Muir*
87
109
 
88
- * Fix Active Storage update task when running in an engine.
110
+ * The ActiveStorage video previewer will now use scene change detection to generate
111
+ better preview images (rather than the previous default of using the first frame
112
+ of the video). This change requires FFmpeg v3.4+.
89
113
 
90
- *Justin Malčić*
114
+ *Jonathan Hefner*
91
115
 
92
- * Don't raise an error if the mime type is not recognized.
116
+ * Add support for ActiveStorage expiring URLs.
93
117
 
94
- Fixes #41777.
118
+ ```ruby
119
+ rails_blob_path(user.avatar, disposition: "attachment", expires_in: 30.minutes)
95
120
 
96
- *Alex Ghiculescu*
121
+ <%= image_tag rails_blob_path(user.avatar.variant(resize: "100x100"), expires_in: 30.minutes) %>
122
+ ```
97
123
 
98
- * `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
124
+ If you want to set default expiration time for ActiveStorage URLs throughout your application, set `config.active_storage.urls_expire_in`.
99
125
 
100
- *Alex Robbin*
126
+ *aki77*
101
127
 
102
- * respond with 404 given invalid variation key when asking for representations.
128
+ * Allow to purge an attachment when record is not persisted for `has_many_attached`.
103
129
 
104
- *George Claghorn*
130
+ *Jacopo Beschi*
105
131
 
106
- * `Blob` creation shouldn't crash if no service selected.
132
+ * Add `with_all_variant_records` method to eager load all variant records on an attachment at once.
133
+ `with_attached_image` scope now eager loads variant records if using variant tracking.
107
134
 
108
135
  *Alex Ghiculescu*
109
136
 
137
+ * Add metadata value for presence of audio channel in video blobs.
110
138
 
111
- ## Rails 6.1.3.2 (May 05, 2021) ##
112
-
113
- * No changes.
114
-
115
-
116
- ## Rails 6.1.3.1 (March 26, 2021) ##
117
-
118
- * Marcel is upgraded to version 1.0.0 to avoid a dependency on GPL-licensed
119
- mime types data.
120
-
121
- *George Claghorn*
122
-
123
-
124
- ## Rails 6.1.3 (February 17, 2021) ##
125
-
126
- * No changes.
127
-
139
+ The `metadata` attribute of video blobs has a new boolean key named `audio` that is set to
140
+ `true` if the file has an audio channel and `false` if it doesn't.
128
141
 
129
- ## Rails 6.1.2.1 (February 10, 2021) ##
142
+ *Breno Gazzola*
130
143
 
131
- * No changes.
144
+ * Adds analyzer for audio files.
132
145
 
146
+ *Breno Gazzola*
133
147
 
134
- ## Rails 6.1.2 (February 09, 2021) ##
148
+ * Respect Active Record's primary_key_type in Active Storage migrations.
135
149
 
136
- * No changes.
137
-
138
-
139
- ## Rails 6.1.1 (January 07, 2021) ##
140
-
141
- * Fix S3 multipart uploads when threshold is larger than file.
142
-
143
- *Matt Muller*
144
-
145
-
146
- ## Rails 6.1.0 (December 09, 2020) ##
147
-
148
- * Change default queue name of the analysis (`:active_storage_analysis`) and
149
- purge (`:active_storage_purge`) jobs to be the job adapter's default (`:default`).
150
-
151
- *Rafael Mendonça França*
152
-
153
- * Implement `strict_loading` on ActiveStorage associations.
154
-
155
- *David Angulo*
156
-
157
- * Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`.
158
-
159
- *Rafael Mendonça França*
160
-
161
- * Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer`.
162
-
163
- *Rafael Mendonça França*
164
-
165
- * Remove deprecated `config.active_storage.queue`.
166
-
167
- *Rafael Mendonça França*
168
-
169
- * Remove deprecated `ActiveStorage::Downloading`.
170
-
171
- *Rafael Mendonça França*
150
+ *fatkodima*
172
151
 
173
- * Add per-environment configuration support
152
+ * Allow `expires_in` for ActiveStorage signed ids.
174
153
 
175
- *Pietro Moro*
154
+ *aki77*
176
155
 
177
- * The Poppler PDF previewer renders a preview image using the original
178
- document's crop box rather than its media box, hiding print margins. This
179
- matches the behavior of the MuPDF previewer.
156
+ * Allow to purge an attachment when record is not persisted for `has_one_attached`.
180
157
 
181
- *Vincent Robert*
158
+ *Jacopo Beschi*
182
159
 
183
- * Touch parent model when an attachment is purged.
160
+ * Add a load hook called `active_storage_variant_record` (providing `ActiveStorage::VariantRecord`)
161
+ to allow for overriding aspects of the `ActiveStorage::VariantRecord` class. This makes
162
+ `ActiveStorage::VariantRecord` consistent with `ActiveStorage::Blob` and `ActiveStorage::Attachment`
163
+ that already have load hooks.
184
164
 
185
- *Víctor Pérez Rodríguez*
165
+ *Brendon Muir*
186
166
 
187
- * Files can now be served by proxying them from the underlying storage service
188
- instead of redirecting to a signed service URL. Use the
189
- `rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
167
+ * `ActiveStorage::PreviewError` is raised when a previewer is unable to generate a preview image.
190
168
 
191
- ```erb
192
- <%= image_tag rails_storage_proxy_path(@user.avatar) %>
193
- ```
169
+ *Alex Robbin*
194
170
 
195
- To proxy by default, set `config.active_storage.resolve_model_to_route`:
171
+ * Add `ActiveStorage::Streaming` module that can be included in a controller to get access to `#send_blob_stream`,
172
+ which wraps the new `ActionController::Base#send_stream` method to stream a blob from cloud storage:
196
173
 
197
174
  ```ruby
198
- # Proxy attached files instead.
199
- config.active_storage.resolve_model_to_route = :rails_storage_proxy
200
- ```
201
-
202
- ```erb
203
- <%= image_tag @user.avatar %>
204
- ```
205
-
206
- To redirect to a signed service URL when the default file serving strategy
207
- is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
208
-
209
- ```erb
210
- <%= image_tag rails_storage_redirect_path(@user.avatar) %>
175
+ class MyPublicBlobsController < ApplicationController
176
+ include ActiveStorage::SetBlob, ActiveStorage::Streaming
177
+
178
+ def show
179
+ http_cache_forever(public: true) do
180
+ send_blob_stream @blob, disposition: params[:disposition]
181
+ end
182
+ end
183
+ end
211
184
  ```
212
185
 
213
- *Jonathan Fleckenstein*
214
-
215
- * Add `config.active_storage.web_image_content_types` to allow applications
216
- to add content types (like `image/webp`) in which variants can be processed,
217
- instead of letting those images be converted to the fallback PNG format.
186
+ *DHH*
218
187
 
219
- *Jeroen van Haperen*
220
-
221
- * Add support for creating variants of `WebP` images out of the box.
222
-
223
- *Dino Maric*
224
-
225
- * Only enqueue analysis jobs for blobs with non-null analyzer classes.
226
-
227
- *Gannon McGibbon*
228
-
229
- * Previews are created on the same service as the original blob.
230
-
231
- *Peter Zhu*
232
-
233
- * Remove unused `disposition` and `content_type` query parameters for `DiskService`.
234
-
235
- *Peter Zhu*
236
-
237
- * Use `DiskController` for both public and private files.
238
-
239
- `DiskController` is able to handle multiple services by adding a
240
- `service_name` field in the generated URL in `DiskService`.
241
-
242
- *Peter Zhu*
243
-
244
- * Variants are tracked in the database to avoid existence checks in the storage service.
245
-
246
- *George Claghorn*
247
-
248
- * Deprecate `service_url` methods in favour of `url`.
249
-
250
- Deprecate `Variant#service_url` and `Preview#service_url` to instead use
251
- `#url` method to be consistent with `Blob`.
252
-
253
- *Peter Zhu*
254
-
255
- * Permanent URLs for public storage blobs.
256
-
257
- Services can be configured in `config/storage.yml` with a new key
258
- `public: true | false` to indicate whether a service holds public
259
- blobs or private blobs. Public services will always return a permanent URL.
260
-
261
- Deprecates `Blob#service_url` in favor of `Blob#url`.
262
-
263
- *Peter Zhu*
264
-
265
- * Make services aware of configuration names.
266
-
267
- *Gannon McGibbon*
268
-
269
- * The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.
270
-
271
- *Kyle Ribordy*
272
-
273
- * Allow storage services to be configured per attachment.
188
+ * Add ability to use pre-defined variants.
274
189
 
275
190
  ```ruby
276
191
  class User < ActiveRecord::Base
277
- has_one_attached :avatar, service: :s3
192
+ has_one_attached :avatar do |attachable|
193
+ attachable.variant :thumb, resize: "100x100"
194
+ attachable.variant :medium, resize: "300x300", monochrome: true
195
+ end
278
196
  end
279
197
 
280
198
  class Gallery < ActiveRecord::Base
281
- has_many_attached :photos, service: :s3
199
+ has_many_attached :photos do |attachable|
200
+ attachable.variant :thumb, resize: "100x100"
201
+ attachable.variant :medium, resize: "300x300", monochrome: true
202
+ end
282
203
  end
283
- ```
284
-
285
- *Dmitry Tsepelev*
286
-
287
- * You can optionally provide a custom blob key when attaching a new file:
288
-
289
- ```ruby
290
- user.avatar.attach key: "avatars/#{user.id}.jpg",
291
- io: io, content_type: "image/jpeg", filename: "avatar.jpg"
292
- ```
293
-
294
- Active Storage will store the blob's data on the configured service at the provided key.
295
-
296
- *George Claghorn*
297
-
298
- * Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
299
-
300
- `create_after_upload!` has been removed since it could lead to data
301
- corruption by uploading to a key on the storage service which happened to
302
- be already taken. Creating the record would then correctly raise a
303
- database uniqueness exception but the stored object would already have
304
- overwritten another. `create_and_upload!` swaps the order of operations
305
- so that the key gets reserved up-front or the uniqueness error gets raised,
306
- before the upload to a key takes place.
307
-
308
- *Julik Tarkhanov*
309
-
310
- * Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
311
-
312
- *Peter Zhu*
313
-
314
- * Allow record to be optionally passed to blob finders to make sharding
315
- easier.
316
-
317
- *Gannon McGibbon*
318
-
319
- * Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
320
-
321
- *Peter Zhu*
322
-
323
- * Add `config.active_storage.draw_routes` to disable Active Storage routes.
324
-
325
- *Gannon McGibbon*
326
-
327
- * Image analysis is skipped if ImageMagick returns an error.
328
204
 
329
- `ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
330
- `MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
331
- failures. It now logs the error and returns `{}`, resulting in no metadata
332
- being added to the offending image blob.
333
-
334
- *George Claghorn*
335
-
336
- * Method calls on singular attachments return `nil` when no file is attached.
337
-
338
- Previously, assuming the following User model, `user.avatar.filename` would
339
- raise a `Module::DelegationError` if no avatar was attached:
340
-
341
- ```ruby
342
- class User < ApplicationRecord
343
- has_one_attached :avatar
344
- end
205
+ <%= image_tag user.avatar.variant(:thumb) %>
345
206
  ```
346
207
 
347
- They now return `nil`.
348
-
349
- *Matthew Tanous*
350
-
351
- * The mirror service supports direct uploads.
352
-
353
- New files are directly uploaded to the primary service. When a
354
- directly-uploaded file is attached to a record, a background job is enqueued
355
- to copy it to each secondary service.
356
-
357
- Configure the queue used to process mirroring jobs by setting
358
- `config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
359
-
360
- *George Claghorn*
361
-
362
- * The S3 service now permits uploading files larger than 5 gigabytes.
208
+ *fatkodima*
363
209
 
364
- When uploading a file greater than 100 megabytes in size, the service
365
- transparently switches to [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
366
- using a part size computed from the file's total size and S3's part count limit.
210
+ * After setting `config.active_storage.resolve_model_to_route = :rails_storage_proxy`
211
+ `rails_blob_path` and `rails_representation_path` will generate proxy URLs by default.
367
212
 
368
- No application changes are necessary to take advantage of this feature. You
369
- can customize the default 100 MB multipart upload threshold in your S3
370
- service's configuration:
213
+ *Ali Ismayilov*
371
214
 
372
- ```yaml
373
- production:
374
- service: s3
375
- access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
376
- secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
377
- region: us-east-1
378
- bucket: my-bucket
379
- upload:
380
- multipart_threshold: <%= 250.megabytes %>
381
- ```
215
+ * Declare `ActiveStorage::FixtureSet` and `ActiveStorage::FixtureSet.blob` to
216
+ improve fixture integration.
382
217
 
383
- *George Claghorn*
218
+ *Sean Doyle*
384
219
 
385
220
 
386
- Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activestorage/CHANGELOG.md) for previous changes.
221
+ Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/activestorage/CHANGELOG.md) for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2022 David Heinemeier Hansson, Basecamp
1
+ Copyright (c) 2017-2021 David Heinemeier Hansson, Basecamp
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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/jpg")
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
- 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:
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 `activestorage.js` in your application's JavaScript bundle.
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