activestorage 5.2.4 → 6.0.0

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -60
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +9 -6
  5. data/app/assets/javascripts/activestorage.js +4 -1
  6. data/app/controllers/active_storage/base_controller.rb +3 -5
  7. data/app/controllers/active_storage/blobs_controller.rb +1 -1
  8. data/app/controllers/active_storage/disk_controller.rb +5 -2
  9. data/app/controllers/active_storage/representations_controller.rb +1 -1
  10. data/app/controllers/concerns/active_storage/set_current.rb +15 -0
  11. data/app/javascript/activestorage/blob_record.js +6 -1
  12. data/app/jobs/active_storage/analyze_job.rb +4 -0
  13. data/app/jobs/active_storage/base_job.rb +0 -1
  14. data/app/jobs/active_storage/purge_job.rb +3 -0
  15. data/app/models/active_storage/attachment.rb +20 -9
  16. data/app/models/active_storage/blob.rb +66 -24
  17. data/app/models/active_storage/blob/representable.rb +5 -5
  18. data/app/models/active_storage/filename.rb +0 -6
  19. data/app/models/active_storage/preview.rb +3 -3
  20. data/app/models/active_storage/variant.rb +51 -52
  21. data/app/models/active_storage/variation.rb +24 -33
  22. data/config/routes.rb +13 -12
  23. data/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb +9 -0
  24. data/lib/active_storage.rb +26 -6
  25. data/lib/active_storage/analyzer.rb +9 -4
  26. data/lib/active_storage/analyzer/image_analyzer.rb +11 -4
  27. data/lib/active_storage/analyzer/video_analyzer.rb +3 -5
  28. data/lib/active_storage/attached.rb +7 -22
  29. data/lib/active_storage/attached/changes.rb +16 -0
  30. data/lib/active_storage/attached/changes/create_many.rb +46 -0
  31. data/lib/active_storage/attached/changes/create_one.rb +69 -0
  32. data/lib/active_storage/attached/changes/create_one_of_many.rb +10 -0
  33. data/lib/active_storage/attached/changes/delete_many.rb +27 -0
  34. data/lib/active_storage/attached/changes/delete_one.rb +19 -0
  35. data/lib/active_storage/attached/many.rb +16 -10
  36. data/lib/active_storage/attached/model.rb +147 -0
  37. data/lib/active_storage/attached/one.rb +16 -19
  38. data/lib/active_storage/downloader.rb +43 -0
  39. data/lib/active_storage/downloading.rb +8 -0
  40. data/lib/active_storage/engine.rb +43 -6
  41. data/lib/active_storage/errors.rb +22 -3
  42. data/lib/active_storage/gem_version.rb +3 -3
  43. data/lib/active_storage/previewer.rb +21 -11
  44. data/lib/active_storage/previewer/poppler_pdf_previewer.rb +2 -2
  45. data/lib/active_storage/previewer/video_previewer.rb +2 -3
  46. data/lib/active_storage/reflection.rb +64 -0
  47. data/lib/active_storage/service.rb +9 -6
  48. data/lib/active_storage/service/azure_storage_service.rb +30 -14
  49. data/lib/active_storage/service/configurator.rb +3 -1
  50. data/lib/active_storage/service/disk_service.rb +19 -11
  51. data/lib/active_storage/service/gcs_service.rb +49 -47
  52. data/lib/active_storage/service/s3_service.rb +10 -6
  53. data/lib/active_storage/transformers/image_processing_transformer.rb +39 -0
  54. data/lib/active_storage/transformers/mini_magick_transformer.rb +38 -0
  55. data/lib/active_storage/transformers/transformer.rb +42 -0
  56. data/lib/tasks/activestorage.rake +7 -0
  57. metadata +39 -13
  58. data/app/models/active_storage/filename/parameters.rb +0 -36
  59. data/lib/active_storage/attached/macros.rb +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b72c9420f7235052fa72e9f13c9df4fb72ae3a36424be0359bb01514cd08a304
4
- data.tar.gz: b56ae498f785ac781dcf4d81f502f6eba480838abfb6abd2f0fa53266c1e8b08
3
+ metadata.gz: 716b00e8dcc27ec9df016cff558ecce99f31470d58bbc7efe3a495b7ab272722
4
+ data.tar.gz: 2986c8c1b288f85025be8fc2f768c6c4370c36b593a81ff68599e1d3e691d7b7
5
5
  SHA512:
6
- metadata.gz: 7e90d469b456d42ff592f3be78dae4ff2eb778a48e55678f961b768429f316a194154e86b997da5d224ddca9b708c83ef134649fb6bedc35a94c668d63ed8308
7
- data.tar.gz: bba66b4b994a4e86f5dcfdc43ae80908d3d223f29c6cf5b0c9f02754810c3c4d6dc06563b859aa657a83b23b8f15638ac82bf039ee0f873a4d36ba37b54d81cd
6
+ metadata.gz: c51640d41c7223552bdf418f1993af9fc49f73c24f002323e7deefcb8610dfddad022a566fb60a8c608081ae39d563e5940f092c291304c8074a0f8d0572120a
7
+ data.tar.gz: c3c6b78ab356d557188ddd05dd8c033bdb2e55b7bde8c0443d0d9b4373d8da081b7f450c2edc1efb0f312d69f5cbd7b8517c6b249160c3719172dc473be88a3f
@@ -1,122 +1,198 @@
1
- ## Rails 5.2.4 (November 27, 2019) ##
1
+ ## Rails 6.0.0 (August 16, 2019) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 5.2.3 (March 27, 2019) ##
6
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
7
7
 
8
8
  * No changes.
9
9
 
10
10
 
11
- ## Rails 5.2.2.1 (March 11, 2019) ##
11
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
12
+
13
+ * Don't raise when analyzing an image whose type is unsupported by ImageMagick.
14
+
15
+ Fixes #36065.
16
+
17
+ *Guilherme Mansur*
18
+
19
+ * Permit generating variants of BMP images.
20
+
21
+ *Younes Serraj*
22
+
23
+
24
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
12
25
 
13
26
  * No changes.
14
27
 
15
28
 
16
- ## Rails 5.2.2 (December 04, 2018) ##
29
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
17
30
 
18
- * Support multiple submit buttons in Active Storage forms.
31
+ * No changes.
19
32
 
20
- *Chrıs Seelus*
21
33
 
22
- * Fix `ArgumentError` when uploading to amazon s3
34
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
23
35
 
24
- *Hiroki Sanpei*
36
+ * [Rename npm package](https://github.com/rails/rails/pull/34905) from
37
+ [`activestorage`](https://www.npmjs.com/package/activestorage) to
38
+ [`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
25
39
 
26
- * Add a foreign-key constraint to the `active_storage_attachments` table for blobs.
40
+ *Javan Makhmali*
27
41
 
28
- *George Claghorn*
42
+ * Replace `config.active_storage.queue` with two options that indicate which
43
+ queues analysis and purge jobs should use, respectively:
29
44
 
30
- * Discard `ActiveStorage::PurgeJobs` for missing blobs.
45
+ * `config.active_storage.queues.analysis`
46
+ * `config.active_storage.queues.purge`
47
+
48
+ `config.active_storage.queue` is preferred over the new options when it's
49
+ set, but it is deprecated and will be removed in Rails 6.1.
31
50
 
32
51
  *George Claghorn*
33
52
 
34
- * Fix uploading Tempfiles to Azure Storage.
53
+ * Permit generating variants of TIFF images.
35
54
 
36
- *George Claghorn*
55
+ *Luciano Sousa*
37
56
 
57
+ * Use base36 (all lowercase) for all new Blob keys to prevent
58
+ collisions and undefined behavior with case-insensitive filesystems and
59
+ database indices.
38
60
 
39
- ## Rails 5.2.1.1 (November 27, 2018) ##
61
+ *Julik Tarkhanov*
40
62
 
41
- * Prevent content type and disposition bypass in storage service URLs.
63
+ * It doesn’t include an `X-CSRF-Token` header if a meta tag is not found on
64
+ the page. It previously included one with a value of `undefined`.
42
65
 
43
- Fix CVE-2018-16477.
66
+ *Cameron Bothner*
44
67
 
45
- *Rosa Gutierrez*
68
+ * Fix `ArgumentError` when uploading to amazon s3
46
69
 
70
+ *Hiroki Sanpei*
47
71
 
48
- ## Rails 5.2.1 (August 07, 2018) ##
72
+ * Add progressive JPG to default list of variable content types
49
73
 
50
- * Fix direct upload with zero-byte files.
74
+ *Maurice Kühlborn*
51
75
 
52
- *George Claghorn*
76
+ * Add `ActiveStorage.routes_prefix` for configuring generated routes.
53
77
 
54
- * Exclude JSON root from `active_storage/direct_uploads#create` response.
78
+ *Chris Bisnett*
55
79
 
56
- *Javan Makhmali*
80
+ * `ActiveStorage::Service::AzureStorageService` only handles specifically
81
+ relevant types of `Azure::Core::Http::HTTPError`. It previously obscured
82
+ other types of `HTTPError`, which is the azure-storage gem’s catch-all
83
+ exception class.
57
84
 
85
+ *Cameron Bothner*
58
86
 
59
- ## Rails 5.2.0 (April 09, 2018) ##
87
+ * `ActiveStorage::DiskController#show` generates a 404 Not Found response when
88
+ the requested file is missing from the disk service. It previously raised
89
+ `Errno::ENOENT`.
60
90
 
61
- * Allow full use of the AWS S3 SDK options for authentication. If an
62
- explicit AWS key pair and/or region is not provided in `storage.yml`,
63
- attempt to use environment variables, shared credentials, or IAM
64
- (instance or task) role credentials. Order of precedence is determined
65
- by the [AWS SDK](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html).
91
+ *Cameron Bothner*
66
92
 
67
- *Brian Knight*
93
+ * `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise
94
+ `ActiveStorage::FileNotFoundError` when the corresponding file is missing
95
+ from the storage service. Services translate service-specific missing object
96
+ exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and
97
+ `Errno::ENOENT` for the disk service) into
98
+ `ActiveStorage::FileNotFoundError`.
68
99
 
69
- * Remove path config option from Azure service.
100
+ *Cameron Bothner*
70
101
 
71
- The Active Storage service for Azure Storage has an option called `path`
72
- that is ambiguous in meaning. It needs to be set to the primary blob
73
- storage endpoint but that can be determined from the blobs client anyway.
102
+ * Added the `ActiveStorage::SetCurrent` concern for custom Active Storage
103
+ controllers that can't inherit from `ActiveStorage::BaseController`.
74
104
 
75
- To simplify the configuration, we've removed the `path` option and
76
- now get the endpoint from the blobs client instead.
105
+ *George Claghorn*
77
106
 
78
- Closes #32225.
107
+ * Active Storage error classes like `ActiveStorage::IntegrityError` and
108
+ `ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
109
+ instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
110
+ handle all Active Storage errors.
79
111
 
80
- *Andrew White*
112
+ *Andrei Makarov*, *George Claghorn*
81
113
 
82
- * Generate root-relative paths in disk service URL methods.
114
+ * Uploaded files assigned to a record are persisted to storage when the record
115
+ is saved instead of immediately.
83
116
 
84
- Obviate the disk service's `:host` configuration option.
117
+ In Rails 5.2, the following causes an uploaded file in `params[:avatar]` to
118
+ be stored:
119
+
120
+ ```ruby
121
+ @user.avatar = params[:avatar]
122
+ ```
123
+
124
+ In Rails 6, the uploaded file is stored when `@user` is successfully saved.
85
125
 
86
126
  *George Claghorn*
87
127
 
88
- * Add source code to published npm package.
128
+ * Add the ability to reflect on defined attachments using the existing
129
+ ActiveRecord reflection mechanism.
130
+
131
+ *Kevin Deisz*
132
+
133
+ * Variant arguments of `false` or `nil` will no longer be passed to the
134
+ processor. For example, the following will not have the monochrome
135
+ variation applied:
136
+
137
+ ```ruby
138
+ avatar.variant(monochrome: false)
139
+ ```
140
+
141
+ *Jacob Smith*
142
+
143
+ * Generated attachment getter and setter methods are created
144
+ within the model's `GeneratedAssociationMethods` module to
145
+ allow overriding and composition using `super`.
146
+
147
+ *Josh Susser*, *Jamon Douglas*
148
+
149
+ * Add `ActiveStorage::Blob#open`, which downloads a blob to a tempfile on disk
150
+ and yields the tempfile. Deprecate `ActiveStorage::Downloading`.
151
+
152
+ *David Robertson*, *George Claghorn*
89
153
 
90
- This allows activestorage users to depend on the javascript source code
91
- rather than the compiled code, which can produce smaller javascript bundles.
154
+ * Pass in `identify: false` as an argument when providing a `content_type` for
155
+ `ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
156
+ type inference. For example:
92
157
 
93
- *Richard Macklin*
158
+ ```ruby
159
+ @message.image.attach(
160
+ io: File.open('/path/to/file'),
161
+ filename: 'file.pdf',
162
+ content_type: 'application/pdf',
163
+ identify: false
164
+ )
165
+ ```
94
166
 
95
- * Preserve display aspect ratio when extracting width and height from videos
96
- with rectangular samples in `ActiveStorage::Analyzer::VideoAnalyzer`.
167
+ *Ryan Davidson*
97
168
 
98
- When a video contains a display aspect ratio, emit it in metadata as
99
- `:display_aspect_ratio` rather than the ambiguous `:aspect_ratio`. Compute
100
- its height by scaling its encoded frame width according to the DAR.
169
+ * The Google Cloud Storage service properly supports streaming downloads.
170
+ It now requires version 1.11 or newer of the google-cloud-storage gem.
101
171
 
102
172
  *George Claghorn*
103
173
 
104
- * Use `after_destroy_commit` instead of `before_destroy` for purging
105
- attachments when a record is destroyed.
174
+ * Use the [ImageProcessing](https://github.com/janko-m/image_processing) gem
175
+ for Active Storage variants, and deprecate the MiniMagick backend.
106
176
 
107
- *Hiroki Zenigami*
177
+ This means that variants are now automatically oriented if the original
178
+ image was rotated. Also, in addition to the existing ImageMagick
179
+ operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
180
+ other ImageProcessing macros. These are now recommended over raw `:resize`,
181
+ as they also sharpen the thumbnail after resizing.
108
182
 
109
- * Force `:attachment` disposition for specific, configurable content types.
110
- This mitigates possible security issues such as XSS or phishing when
111
- serving them inline. A list of such content types is included by default,
112
- and can be configured via `content_types_to_serve_as_binary`.
183
+ The ImageProcessing gem also comes with a backend implemented on
184
+ [libvips](http://jcupitt.github.io/libvips/), an alternative to
185
+ ImageMagick which has significantly better performance than
186
+ ImageMagick in most cases, both in terms of speed and memory usage. In
187
+ Active Storage it's now possible to switch to the libvips backend by
188
+ changing `Rails.application.config.active_storage.variant_processor` to
189
+ `:vips`.
113
190
 
114
- *Rosa Gutierrez*
191
+ *Janko Marohnić*
115
192
 
116
- * Fix the gem adding the migrations files to the package.
193
+ * Rails 6 requires Ruby 2.5.0 or newer.
117
194
 
118
- *Yuji Yaginuma*
195
+ *Jeremy Daer*, *Kasper Timm Hansen*
119
196
 
120
- * Added to Rails.
121
197
 
122
- *DHH*
198
+ Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activestorage/CHANGELOG.md) for previous changes.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2018 David Heinemeier Hansson, Basecamp
1
+ Copyright (c) 2017-2019 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
@@ -4,11 +4,13 @@ Active Storage makes it simple to upload and reference files in cloud services l
4
4
 
5
5
  Files can be uploaded from the server to the cloud or directly from the client to the cloud.
6
6
 
7
- Image files can furthermore be transformed using on-demand variants for quality, aspect ratio, size, or any other [MiniMagick](https://github.com/minimagick/minimagick) supported transformation.
7
+ Image files can furthermore be transformed using on-demand variants for quality, aspect ratio, size, or any other [MiniMagick](https://github.com/minimagick/minimagick) or [Vips](https://www.rubydoc.info/gems/ruby-vips/Vips/Image) supported transformation.
8
+
9
+ You can read more about Active Storage in the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) guide.
8
10
 
9
11
  ## Compared to other storage solutions
10
12
 
11
- A key difference to how Active Storage works compared to other attachment solutions in Rails is through the use of built-in [Blob](https://github.com/rails/rails/blob/5-2-stable/activestorage/app/models/active_storage/blob.rb) and [Attachment](https://github.com/rails/rails/blob/5-2-stable/activestorage/app/models/active_storage/attachment.rb) models (backed by Active Record). This means existing application models do not need to be modified with additional columns to associate with files. Active Storage uses polymorphic associations via the `Attachment` join model, which then connects to the actual `Blob`.
13
+ A key difference to how Active Storage works compared to other attachment solutions in Rails is through the use of built-in [Blob](https://github.com/rails/rails/blob/master/activestorage/app/models/active_storage/blob.rb) and [Attachment](https://github.com/rails/rails/blob/master/activestorage/app/models/active_storage/attachment.rb) models (backed by Active Record). This means existing application models do not need to be modified with additional columns to associate with files. Active Storage uses polymorphic associations via the `Attachment` join model, which then connects to the actual `Blob`.
12
14
 
13
15
  `Blob` models store attachment metadata (filename, content-type, etc.), and their identifier key in the storage service. Blob models do not store the actual binary data. They are intended to be immutable in spirit. One file, one blob. You can associate the same blob with multiple application models as well. And if you want to do transformations of a given `Blob`, the idea is that you'll simply create a new one, rather than attempt to mutate the existing one (though of course you can delete the previous version later if you don't need it).
14
16
 
@@ -16,6 +18,8 @@ A key difference to how Active Storage works compared to other attachment soluti
16
18
 
17
19
  Run `rails active_storage:install` to copy over active_storage migrations.
18
20
 
21
+ NOTE: If the task cannot be found, verify that `require "active_storage/engine"` is present in `config/application.rb`.
22
+
19
23
  ## Examples
20
24
 
21
25
  One attachment:
@@ -99,7 +103,7 @@ Variation of image attachment:
99
103
 
100
104
  ```erb
101
105
  <%# Hitting the variant URL will lazy transform the original blob and then redirect to its new service location %>
102
- <%= image_tag user.avatar.variant(resize: "100x100") %>
106
+ <%= image_tag user.avatar.variant(resize_to_limit: [100, 100]) %>
103
107
  ```
104
108
 
105
109
  ## Direct uploads
@@ -116,8 +120,7 @@ Active Storage, with its included JavaScript library, supports uploading directl
116
120
  ```
117
121
  Using the npm package:
118
122
  ```js
119
- import * as ActiveStorage from "activestorage"
120
- ActiveStorage.start()
123
+ require("@rails/activestorage").start()
121
124
  ```
122
125
  2. Annotate file inputs with the direct upload URL.
123
126
 
@@ -148,7 +151,7 @@ Active Storage is released under the [MIT License](https://opensource.org/licens
148
151
 
149
152
  API documentation is at:
150
153
 
151
- * http://api.rubyonrails.org
154
+ * https://api.rubyonrails.org
152
155
 
153
156
  Bug reports for the Ruby on Rails project can be filed here:
154
157
 
@@ -560,7 +560,10 @@
560
560
  this.xhr.setRequestHeader("Content-Type", "application/json");
561
561
  this.xhr.setRequestHeader("Accept", "application/json");
562
562
  this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
563
- this.xhr.setRequestHeader("X-CSRF-Token", getMetaValue("csrf-token"));
563
+ var csrfToken = getMetaValue("csrf-token");
564
+ if (csrfToken != undefined) {
565
+ this.xhr.setRequestHeader("X-CSRF-Token", csrfToken);
566
+ }
564
567
  this.xhr.addEventListener("load", function(event) {
565
568
  return _this.requestDidLoad(event);
566
569
  });
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # The base controller for all ActiveStorage controllers.
3
+ # The base class for all Active Storage controllers.
4
4
  class ActiveStorage::BaseController < ActionController::Base
5
- protect_from_forgery with: :exception
5
+ include ActiveStorage::SetCurrent
6
6
 
7
- before_action do
8
- ActiveStorage::Current.host = request.base_url
9
- end
7
+ protect_from_forgery with: :exception
10
8
  end
@@ -8,7 +8,7 @@ class ActiveStorage::BlobsController < ActiveStorage::BaseController
8
8
  include ActiveStorage::SetBlob
9
9
 
10
10
  def show
11
- expires_in ActiveStorage::Blob.service.url_expires_in
11
+ expires_in ActiveStorage.service_urls_expire_in
12
12
  redirect_to @blob.service_url(disposition: params[:disposition])
13
13
  end
14
14
  end
@@ -3,7 +3,7 @@
3
3
  # Serves files stored with the disk service in the same way that the cloud services do.
4
4
  # This means using expiring, signed URLs that are meant for immediate access, not permanent linking.
5
5
  # Always go through the BlobsController, or your own authenticated controller, rather than directly
6
- # to the service url.
6
+ # to the service URL.
7
7
  class ActiveStorage::DiskController < ActiveStorage::BaseController
8
8
  skip_forgery_protection
9
9
 
@@ -13,16 +13,19 @@ class ActiveStorage::DiskController < ActiveStorage::BaseController
13
13
  else
14
14
  head :not_found
15
15
  end
16
+ rescue Errno::ENOENT
17
+ head :not_found
16
18
  end
17
19
 
18
20
  def update
19
21
  if token = decode_verified_token
20
22
  if acceptable_content?(token)
21
23
  disk_service.upload token[:key], request.body, checksum: token[:checksum]
22
- head :no_content
23
24
  else
24
25
  head :unprocessable_entity
25
26
  end
27
+ else
28
+ head :not_found
26
29
  end
27
30
  rescue ActiveStorage::IntegrityError
28
31
  head :unprocessable_entity
@@ -8,7 +8,7 @@ class ActiveStorage::RepresentationsController < ActiveStorage::BaseController
8
8
  include ActiveStorage::SetBlob
9
9
 
10
10
  def show
11
- expires_in ActiveStorage::Blob.service.url_expires_in
11
+ expires_in ActiveStorage.service_urls_expire_in
12
12
  redirect_to @blob.representation(params[:variation_key]).processed.service_url(disposition: params[:disposition])
13
13
  end
14
14
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Sets the <tt>ActiveStorage::Current.host</tt> attribute, which the disk service uses to generate URLs.
4
+ # Include this concern in custom controllers that call ActiveStorage::Blob#service_url,
5
+ # ActiveStorage::Variant#service_url, or ActiveStorage::Preview#service_url so the disk service can
6
+ # generate URLs using the same host, protocol, and base path as the current request.
7
+ module ActiveStorage::SetCurrent
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ before_action do
12
+ ActiveStorage::Current.host = request.base_url
13
+ end
14
+ end
15
+ end
@@ -17,7 +17,12 @@ export class BlobRecord {
17
17
  this.xhr.setRequestHeader("Content-Type", "application/json")
18
18
  this.xhr.setRequestHeader("Accept", "application/json")
19
19
  this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
20
- this.xhr.setRequestHeader("X-CSRF-Token", getMetaValue("csrf-token"))
20
+
21
+ const csrfToken = getMetaValue("csrf-token")
22
+ if (csrfToken != undefined) {
23
+ this.xhr.setRequestHeader("X-CSRF-Token", csrfToken)
24
+ }
25
+
21
26
  this.xhr.addEventListener("load", event => this.requestDidLoad(event))
22
27
  this.xhr.addEventListener("error", event => this.requestDidError(event))
23
28
  }
@@ -2,6 +2,10 @@
2
2
 
3
3
  # Provides asynchronous analysis of ActiveStorage::Blob records via ActiveStorage::Blob#analyze_later.
4
4
  class ActiveStorage::AnalyzeJob < ActiveStorage::BaseJob
5
+ queue_as { ActiveStorage.queues[:analysis] }
6
+
7
+ retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer
8
+
5
9
  def perform(blob)
6
10
  blob.analyze
7
11
  end