mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Add ActiveStorage.service_configurations and ActiveStorage.service"
This reverts commit 002684e36e
.
This commit is contained in:
parent
d2542882b2
commit
7c5814c6e0
4 changed files with 28 additions and 34 deletions
|
@ -29,7 +29,7 @@ class ActiveStorage::Blob < ActiveRecord::Base
|
|||
has_secure_token :key
|
||||
store :metadata, accessors: [ :analyzed, :identified ], coder: ActiveRecord::Coders::JSON
|
||||
|
||||
class_attribute :service, default: ActiveStorage.service
|
||||
class_attribute :service
|
||||
|
||||
has_many :attachments
|
||||
|
||||
|
|
|
@ -41,25 +41,19 @@ module ActiveStorage
|
|||
autoload :Previewer
|
||||
autoload :Analyzer
|
||||
|
||||
mattr_accessor :service_configurations, default: {}
|
||||
mattr_accessor :service
|
||||
|
||||
mattr_accessor :queues, default: {}
|
||||
mattr_accessor :previewers, default: []
|
||||
mattr_accessor :analyzers, default: []
|
||||
mattr_accessor :variant_processor, default: :mini_magick
|
||||
mattr_accessor :paths, default: {}
|
||||
|
||||
mattr_accessor :variable_content_types, default: []
|
||||
mattr_accessor :content_types_to_serve_as_binary, default: []
|
||||
mattr_accessor :content_types_allowed_inline, default: []
|
||||
mattr_accessor :binary_content_type, default: "application/octet-stream"
|
||||
|
||||
mattr_accessor :service_urls_expire_in, default: 5.minutes
|
||||
mattr_accessor :routes_prefix, default: "/rails/active_storage"
|
||||
|
||||
mattr_accessor :logger
|
||||
mattr_accessor :verifier
|
||||
mattr_accessor :queues, default: {}
|
||||
mattr_accessor :previewers, default: []
|
||||
mattr_accessor :analyzers, default: []
|
||||
mattr_accessor :variant_processor, default: :mini_magick
|
||||
mattr_accessor :paths, default: {}
|
||||
mattr_accessor :variable_content_types, default: []
|
||||
mattr_accessor :content_types_to_serve_as_binary, default: []
|
||||
mattr_accessor :content_types_allowed_inline, default: []
|
||||
mattr_accessor :binary_content_type, default: "application/octet-stream"
|
||||
mattr_accessor :service_urls_expire_in, default: 5.minutes
|
||||
mattr_accessor :routes_prefix, default: "/rails/active_storage"
|
||||
|
||||
module Transformers
|
||||
extend ActiveSupport::Autoload
|
||||
|
|
|
@ -95,25 +95,25 @@ module ActiveStorage
|
|||
end
|
||||
|
||||
initializer "active_storage.services" do
|
||||
config.after_initialize do |app|
|
||||
ActiveStorage.service_configurations = begin
|
||||
config_file = Pathname.new(Rails.root.join("config/storage.yml"))
|
||||
raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
|
||||
ActiveSupport.on_load(:active_storage_blob) do
|
||||
if config_choice = Rails.configuration.active_storage.service
|
||||
configs = Rails.configuration.active_storage.service_configurations ||= begin
|
||||
config_file = Pathname.new(Rails.root.join("config/storage.yml"))
|
||||
raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
|
||||
|
||||
require "yaml"
|
||||
require "erb"
|
||||
require "yaml"
|
||||
require "erb"
|
||||
|
||||
YAML.load(ERB.new(config_file.read).result) || {}
|
||||
rescue Psych::SyntaxError => e
|
||||
raise "YAML syntax error occurred while parsing #{config_file}. " \
|
||||
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
||||
"Error: #{e.message}"
|
||||
end
|
||||
YAML.load(ERB.new(config_file.read).result) || {}
|
||||
rescue Psych::SyntaxError => e
|
||||
raise "YAML syntax error occurred while parsing #{config_file}. " \
|
||||
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
||||
"Error: #{e.message}"
|
||||
end
|
||||
|
||||
if global_service_name = app.config.active_storage.service
|
||||
ActiveStorage.service =
|
||||
ActiveStorage::Blob.service =
|
||||
begin
|
||||
ActiveStorage::Service.configure(global_service_name)
|
||||
ActiveStorage::Service.configure config_choice, configs
|
||||
rescue => e
|
||||
raise e, "Cannot load `Rails.config.active_storage.service`:\n#{e.message}", e.backtrace
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module ActiveStorage
|
|||
# Configure an Active Storage service by name from a set of configurations,
|
||||
# typically loaded from a YAML file. The Active Storage engine uses this
|
||||
# to set the global Active Storage service when the app boots.
|
||||
def configure(service_name, configurations = ActiveStorage.service_configurations)
|
||||
def configure(service_name, configurations)
|
||||
Configurator.build(service_name, configurations)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue