aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/README.md3
-rw-r--r--activestorage/activestorage.gemspec2
-rw-r--r--activestorage/app/controllers/active_storage/variants_controller.rb2
-rw-r--r--activestorage/app/models/active_storage/attachment.rb3
-rw-r--r--activestorage/app/models/active_storage/blob.rb22
-rw-r--r--activestorage/app/models/active_storage/variation.rb2
-rw-r--r--activestorage/config/routes.rb2
-rw-r--r--activestorage/lib/active_storage/attached.rb4
-rw-r--r--activestorage/lib/active_storage/engine.rb4
-rw-r--r--activestorage/lib/active_storage/service/disk_service.rb6
-rw-r--r--activestorage/test/service/s3_service_test.rb2
11 files changed, 27 insertions, 25 deletions
diff --git a/activestorage/README.md b/activestorage/README.md
index f868e0d708..22e77e2837 100644
--- a/activestorage/README.md
+++ b/activestorage/README.md
@@ -88,7 +88,8 @@ Variation of image attachment:
1. Run `rails activestorage:install` to create needed directories, migrations, and configuration.
2. Optional: Add `gem "aws-sdk", "~> 2"` to your Gemfile if you want to use AWS S3.
3. Optional: Add `gem "google-cloud-storage", "~> 1.3"` to your Gemfile if you want to use Google Cloud Storage.
-4. Optional: Add `gem "mini_magick"` to your Gemfile if you want to use variants.
+4. Optional: Add `gem "azure-storage"` to your Gemfile if you want to use Microsoft Azure.
+5. Optional: Add `gem "mini_magick"` to your Gemfile if you want to use variants.
## Direct uploads
diff --git a/activestorage/activestorage.gemspec b/activestorage/activestorage.gemspec
index 2d4a1f7569..911e1a0469 100644
--- a/activestorage/activestorage.gemspec
+++ b/activestorage/activestorage.gemspec
@@ -27,4 +27,4 @@ Gem::Specification.new do |s|
s.add_dependency "actionpack", version
s.add_dependency "activerecord", version
-end \ No newline at end of file
+end
diff --git a/activestorage/app/controllers/active_storage/variants_controller.rb b/activestorage/app/controllers/active_storage/variants_controller.rb
index aa38f8e928..994c57aafd 100644
--- a/activestorage/app/controllers/active_storage/variants_controller.rb
+++ b/activestorage/app/controllers/active_storage/variants_controller.rb
@@ -1,5 +1,3 @@
-require "active_storage/variant"
-
# Take a signed permanent reference for a variant and turn it into an expiring service URL for download.
# Note: These URLs are publicly accessible. If you need to enforce access protection beyond the
# security-through-obscurity factor of the signed blob and variation reference, you'll need to implement your own
diff --git a/activestorage/app/models/active_storage/attachment.rb b/activestorage/app/models/active_storage/attachment.rb
index 2c8b7a9cf2..e94fc69bba 100644
--- a/activestorage/app/models/active_storage/attachment.rb
+++ b/activestorage/app/models/active_storage/attachment.rb
@@ -1,7 +1,6 @@
-require "active_storage/blob"
require "active_support/core_ext/module/delegation"
-# Attachments associate records with blobs. Usually that's a one record-many blobs relationship,
+# Attachments associate records with blobs. Usually that's a one record-many blobs relationship,
# but it is possible to associate many different records with the same blob. If you're doing that,
# you'll want to declare with `has_one/many_attached :thingy, dependent: false`, so that destroying
# any one record won't destroy the blob as well. (Then you'll need to do your own garbage collecting, though).
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 9208d36ee3..debc62bd41 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -1,9 +1,3 @@
-require "active_storage/service"
-require "active_storage/filename"
-require "active_storage/purge_job"
-require "active_storage/variant"
-require "active_storage/variation"
-
# A blob is a record that contains the metadata about a file and a key for where that file resides on the service.
# Blobs can be created in two ways:
#
@@ -85,16 +79,24 @@ class ActiveStorage::Blob < ActiveRecord::Base
end
# Returns true if the content_type of this blob is in the image range, like image/png.
- def image?() content_type =~ /^image/ end
+ def image?
+ content_type =~ /^image/
+ end
# Returns true if the content_type of this blob is in the audio range, like audio/mpeg.
- def audio?() content_type =~ /^audio/ end
+ def audio?
+ content_type =~ /^audio/
+ end
# Returns true if the content_type of this blob is in the video range, like video/mp4.
- def video?() content_type =~ /^video/ end
+ def video?
+ content_type =~ /^video/
+ end
# Returns true if the content_type of this blob is in the text range, like text/plain.
- def text?() content_type =~ /^text/ end
+ def text?
+ content_type =~ /^text/
+ end
# Returns a `ActiveStorage::Variant` instance with the set of `transformations` passed in. This is only relevant
# for image files, and it allows any image to be transformed for size, colors, and the like. Example:
diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb
index 34b854fd9f..e784506b4c 100644
--- a/activestorage/app/models/active_storage/variation.rb
+++ b/activestorage/app/models/active_storage/variation.rb
@@ -1,6 +1,6 @@
require "active_support/core_ext/object/inclusion"
-# A set of transformations that can be applied to a blob to create a variant. This class is exposed via
+# A set of transformations that can be applied to a blob to create a variant. This class is exposed via
# the `ActiveStorage::Blob#variant` method and should rarely be used directly.
#
# In case you do need to use this directly, it's instantiated using a hash of transformations where
diff --git a/activestorage/config/routes.rb b/activestorage/config/routes.rb
index 6aa99c42ac..fddbb93255 100644
--- a/activestorage/config/routes.rb
+++ b/activestorage/config/routes.rb
@@ -9,7 +9,7 @@ Rails.application.routes.draw do
resolve("ActiveStorage::Attachment") { |attachment| route_for(:rails_blob, attachment.blob) }
- get "/rails/active_storage/variants/:signed_blob_id/:variation_key/*filename" => "active_storage/variants#show", as: :rails_blob_variation
+ get "/rails/active_storage/variants/:signed_blob_id/:variation_key/*filename" => "active_storage/variants#show", as: :rails_blob_variation
direct :rails_variant do |variant|
signed_blob_id = variant.blob.signed_id
diff --git a/activestorage/lib/active_storage/attached.rb b/activestorage/lib/active_storage/attached.rb
index 4644d74bcc..2dbf841864 100644
--- a/activestorage/lib/active_storage/attached.rb
+++ b/activestorage/lib/active_storage/attached.rb
@@ -1,6 +1,4 @@
-require "active_storage/blob"
-require "active_storage/attachment"
-
+require "action_dispatch"
require "action_dispatch/http/upload"
require "active_support/core_ext/module/delegation"
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index 89e61163f5..1d345920fa 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -27,7 +27,9 @@ module ActiveStorage
initializer "active_storage.verifier" do
config.after_initialize do |app|
- ActiveStorage.verifier = app.message_verifier("ActiveStorage")
+ if app.config.secret_key_base.present?
+ ActiveStorage.verifier = app.message_verifier("ActiveStorage")
+ end
end
end
diff --git a/activestorage/lib/active_storage/service/disk_service.rb b/activestorage/lib/active_storage/service/disk_service.rb
index 35b0909297..c75c1caabe 100644
--- a/activestorage/lib/active_storage/service/disk_service.rb
+++ b/activestorage/lib/active_storage/service/disk_service.rb
@@ -81,8 +81,10 @@ class ActiveStorage::Service::DiskService < ActiveStorage::Service
content_length: content_length,
checksum: checksum
},
- expires_in: expires_in,
- purpose: :blob_token
+ {
+ expires_in: expires_in,
+ purpose: :blob_token
+ }
)
generated_url =
diff --git a/activestorage/test/service/s3_service_test.rb b/activestorage/test/service/s3_service_test.rb
index 23b94f25ed..ec80cbce61 100644
--- a/activestorage/test/service/s3_service_test.rb
+++ b/activestorage/test/service/s3_service_test.rb
@@ -35,7 +35,7 @@ if SERVICE_CONFIGURATIONS[:s3] && SERVICE_CONFIGURATIONS[:s3][:access_key_id].pr
end
test "uploading with server-side encryption" do
- config = SERVICE_CONFIGURATIONS.deep_merge(s3: { upload: { server_side_encryption: "AES256" }})
+ config = SERVICE_CONFIGURATIONS.deep_merge(s3: { upload: { server_side_encryption: "AES256" } })
service = ActiveStorage::Service.configure(:s3, config)
begin