activestorage 5.2.4.rc1 → 6.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activestorage might be problematic. Click here for more details.

Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +131 -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 +23 -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 +4 -4
  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 +20 -16
  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: 559e9060c795a26d5257347fac7963777e9761e9815264f56361e7f9ef99d2c5
4
- data.tar.gz: 145db20b023b128a55484f484807e308a3f15985d6343fcaf6e4d6713507ab94
3
+ metadata.gz: af49cf1a74d49cb0cb8a875f1d4686133abecb3695d3fcca94146c74fab99ecf
4
+ data.tar.gz: 97dc69ed43e2265302721f09c5c551d991c674a8ee09a414a1bbfcfb2314cd9d
5
5
  SHA512:
6
- metadata.gz: f3fa788f237112d6a997c8bf587b4669fadce5a9d2bb97403a85b2fcce15830bcacb24f0c6e3d5eaf4387f4c0d577f105f69104ef59f65fac93cb633898deb44
7
- data.tar.gz: 7e65b559068720a3e706b6c41737a6446c7363b023f143f1052fc6f4fb2febe5d7d67e8054a01accc899ce7b245480f49322eb43d6f49062d246e2b88f4c7298
6
+ metadata.gz: 5b9d898d2c468a84e0f64edf12a2ba16d8bcc7f6676cbceb0643e32d3145f72f26b4be7cbe2f03691cf9b0de66b55c9ad0754e5210e59393a6ccf1f64e783817
7
+ data.tar.gz: e8c5a734a377b9bc70c92d3939de87c28ef06f869738992a8ef70ab39ae3d1686218a36516a3eeabe1f790dd58e3886052a0ccb557e0e3af6d7deb6ec5aa6fbb
@@ -1,122 +1,193 @@
1
- ## Rails 5.2.4.rc1 (November 22, 2019) ##
1
+ ## Rails 6.0.0.rc2 (July 22, 2019) ##
2
2
 
3
3
  * No changes.
4
4
 
5
5
 
6
- ## Rails 5.2.3 (March 27, 2019) ##
6
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
7
+
8
+ * Don't raise when analyzing an image whose type is unsupported by ImageMagick.
9
+
10
+ Fixes #36065.
11
+
12
+ *Guilherme Mansur*
13
+
14
+ * Permit generating variants of BMP images.
15
+
16
+ *Younes Serraj*
17
+
18
+
19
+ ## Rails 6.0.0.beta3 (March 11, 2019) ##
7
20
 
8
21
  * No changes.
9
22
 
10
23
 
11
- ## Rails 5.2.2.1 (March 11, 2019) ##
24
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
12
25
 
13
26
  * No changes.
14
27
 
15
28
 
16
- ## Rails 5.2.2 (December 04, 2018) ##
29
+ ## Rails 6.0.0.beta1 (January 18, 2019) ##
17
30
 
18
- * Support multiple submit buttons in Active Storage forms.
31
+ * [Rename npm package](https://github.com/rails/rails/pull/34905) from
32
+ [`activestorage`](https://www.npmjs.com/package/activestorage) to
33
+ [`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
19
34
 
20
- *Chrıs Seelus*
35
+ *Javan Makhmali*
21
36
 
22
- * Fix `ArgumentError` when uploading to amazon s3
37
+ * Replace `config.active_storage.queue` with two options that indicate which
38
+ queues analysis and purge jobs should use, respectively:
23
39
 
24
- *Hiroki Sanpei*
40
+ * `config.active_storage.queues.analysis`
41
+ * `config.active_storage.queues.purge`
25
42
 
26
- * Add a foreign-key constraint to the `active_storage_attachments` table for blobs.
43
+ `config.active_storage.queue` is preferred over the new options when it's
44
+ set, but it is deprecated and will be removed in Rails 6.1.
27
45
 
28
46
  *George Claghorn*
29
47
 
30
- * Discard `ActiveStorage::PurgeJobs` for missing blobs.
48
+ * Permit generating variants of TIFF images.
31
49
 
32
- *George Claghorn*
50
+ *Luciano Sousa*
33
51
 
34
- * Fix uploading Tempfiles to Azure Storage.
52
+ * Use base36 (all lowercase) for all new Blob keys to prevent
53
+ collisions and undefined behavior with case-insensitive filesystems and
54
+ database indices.
35
55
 
36
- *George Claghorn*
56
+ *Julik Tarkhanov*
37
57
 
58
+ * It doesn’t include an `X-CSRF-Token` header if a meta tag is not found on
59
+ the page. It previously included one with a value of `undefined`.
38
60
 
39
- ## Rails 5.2.1.1 (November 27, 2018) ##
61
+ *Cameron Bothner*
40
62
 
41
- * Prevent content type and disposition bypass in storage service URLs.
63
+ * Fix `ArgumentError` when uploading to amazon s3
42
64
 
43
- Fix CVE-2018-16477.
65
+ *Hiroki Sanpei*
44
66
 
45
- *Rosa Gutierrez*
67
+ * Add progressive JPG to default list of variable content types
46
68
 
69
+ *Maurice Kühlborn*
47
70
 
48
- ## Rails 5.2.1 (August 07, 2018) ##
71
+ * Add `ActiveStorage.routes_prefix` for configuring generated routes.
49
72
 
50
- * Fix direct upload with zero-byte files.
73
+ *Chris Bisnett*
51
74
 
52
- *George Claghorn*
75
+ * `ActiveStorage::Service::AzureStorageService` only handles specifically
76
+ relevant types of `Azure::Core::Http::HTTPError`. It previously obscured
77
+ other types of `HTTPError`, which is the azure-storage gem’s catch-all
78
+ exception class.
53
79
 
54
- * Exclude JSON root from `active_storage/direct_uploads#create` response.
80
+ *Cameron Bothner*
55
81
 
56
- *Javan Makhmali*
82
+ * `ActiveStorage::DiskController#show` generates a 404 Not Found response when
83
+ the requested file is missing from the disk service. It previously raised
84
+ `Errno::ENOENT`.
57
85
 
86
+ *Cameron Bothner*
58
87
 
59
- ## Rails 5.2.0 (April 09, 2018) ##
88
+ * `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise
89
+ `ActiveStorage::FileNotFoundError` when the corresponding file is missing
90
+ from the storage service. Services translate service-specific missing object
91
+ exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and
92
+ `Errno::ENOENT` for the disk service) into
93
+ `ActiveStorage::FileNotFoundError`.
60
94
 
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).
95
+ *Cameron Bothner*
66
96
 
67
- *Brian Knight*
97
+ * Added the `ActiveStorage::SetCurrent` concern for custom Active Storage
98
+ controllers that can't inherit from `ActiveStorage::BaseController`.
68
99
 
69
- * Remove path config option from Azure service.
100
+ *George Claghorn*
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
+ * Active Storage error classes like `ActiveStorage::IntegrityError` and
103
+ `ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
104
+ instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
105
+ handle all Active Storage errors.
74
106
 
75
- To simplify the configuration, we've removed the `path` option and
76
- now get the endpoint from the blobs client instead.
107
+ *Andrei Makarov*, *George Claghorn*
77
108
 
78
- Closes #32225.
109
+ * Uploaded files assigned to a record are persisted to storage when the record
110
+ is saved instead of immediately.
79
111
 
80
- *Andrew White*
112
+ In Rails 5.2, the following causes an uploaded file in `params[:avatar]` to
113
+ be stored:
81
114
 
82
- * Generate root-relative paths in disk service URL methods.
115
+ ```ruby
116
+ @user.avatar = params[:avatar]
117
+ ```
83
118
 
84
- Obviate the disk service's `:host` configuration option.
119
+ In Rails 6, the uploaded file is stored when `@user` is successfully saved.
85
120
 
86
121
  *George Claghorn*
87
122
 
88
- * Add source code to published npm package.
123
+ * Add the ability to reflect on defined attachments using the existing
124
+ ActiveRecord reflection mechanism.
125
+
126
+ *Kevin Deisz*
127
+
128
+ * Variant arguments of `false` or `nil` will no longer be passed to the
129
+ processor. For example, the following will not have the monochrome
130
+ variation applied:
131
+
132
+ ```ruby
133
+ avatar.variant(monochrome: false)
134
+ ```
135
+
136
+ *Jacob Smith*
137
+
138
+ * Generated attachment getter and setter methods are created
139
+ within the model's `GeneratedAssociationMethods` module to
140
+ allow overriding and composition using `super`.
141
+
142
+ *Josh Susser*, *Jamon Douglas*
143
+
144
+ * Add `ActiveStorage::Blob#open`, which downloads a blob to a tempfile on disk
145
+ and yields the tempfile. Deprecate `ActiveStorage::Downloading`.
146
+
147
+ *David Robertson*, *George Claghorn*
89
148
 
90
- This allows activestorage users to depend on the javascript source code
91
- rather than the compiled code, which can produce smaller javascript bundles.
149
+ * Pass in `identify: false` as an argument when providing a `content_type` for
150
+ `ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
151
+ type inference. For example:
92
152
 
93
- *Richard Macklin*
153
+ ```ruby
154
+ @message.image.attach(
155
+ io: File.open('/path/to/file'),
156
+ filename: 'file.pdf',
157
+ content_type: 'application/pdf',
158
+ identify: false
159
+ )
160
+ ```
94
161
 
95
- * Preserve display aspect ratio when extracting width and height from videos
96
- with rectangular samples in `ActiveStorage::Analyzer::VideoAnalyzer`.
162
+ *Ryan Davidson*
97
163
 
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.
164
+ * The Google Cloud Storage service properly supports streaming downloads.
165
+ It now requires version 1.11 or newer of the google-cloud-storage gem.
101
166
 
102
167
  *George Claghorn*
103
168
 
104
- * Use `after_destroy_commit` instead of `before_destroy` for purging
105
- attachments when a record is destroyed.
169
+ * Use the [ImageProcessing](https://github.com/janko-m/image_processing) gem
170
+ for Active Storage variants, and deprecate the MiniMagick backend.
106
171
 
107
- *Hiroki Zenigami*
172
+ This means that variants are now automatically oriented if the original
173
+ image was rotated. Also, in addition to the existing ImageMagick
174
+ operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
175
+ other ImageProcessing macros. These are now recommended over raw `:resize`,
176
+ as they also sharpen the thumbnail after resizing.
108
177
 
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`.
178
+ The ImageProcessing gem also comes with a backend implemented on
179
+ [libvips](http://jcupitt.github.io/libvips/), an alternative to
180
+ ImageMagick which has significantly better performance than
181
+ ImageMagick in most cases, both in terms of speed and memory usage. In
182
+ Active Storage it's now possible to switch to the libvips backend by
183
+ changing `Rails.application.config.active_storage.variant_processor` to
184
+ `:vips`.
113
185
 
114
- *Rosa Gutierrez*
186
+ *Janko Marohnić*
115
187
 
116
- * Fix the gem adding the migrations files to the package.
188
+ * Rails 6 requires Ruby 2.5.0 or newer.
117
189
 
118
- *Yuji Yaginuma*
190
+ *Jeremy Daer*, *Kasper Timm Hansen*
119
191
 
120
- * Added to Rails.
121
192
 
122
- *DHH*
193
+ 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
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ActiveStorage::BaseJob < ActiveJob::Base
4
- queue_as { ActiveStorage.queue }
5
4
  end