activestorage 6.1.4 → 7.0.0.rc1

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