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
|
has_secure_token :key
|
||||||
store :metadata, accessors: [ :analyzed, :identified ], coder: ActiveRecord::Coders::JSON
|
store :metadata, accessors: [ :analyzed, :identified ], coder: ActiveRecord::Coders::JSON
|
||||||
|
|
||||||
class_attribute :service, default: ActiveStorage.service
|
class_attribute :service
|
||||||
|
|
||||||
has_many :attachments
|
has_many :attachments
|
||||||
|
|
||||||
|
|
|
@ -41,25 +41,19 @@ module ActiveStorage
|
||||||
autoload :Previewer
|
autoload :Previewer
|
||||||
autoload :Analyzer
|
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 :logger
|
||||||
mattr_accessor :verifier
|
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
|
module Transformers
|
||||||
extend ActiveSupport::Autoload
|
extend ActiveSupport::Autoload
|
||||||
|
|
|
@ -95,25 +95,25 @@ module ActiveStorage
|
||||||
end
|
end
|
||||||
|
|
||||||
initializer "active_storage.services" do
|
initializer "active_storage.services" do
|
||||||
config.after_initialize do |app|
|
ActiveSupport.on_load(:active_storage_blob) do
|
||||||
ActiveStorage.service_configurations = begin
|
if config_choice = Rails.configuration.active_storage.service
|
||||||
config_file = Pathname.new(Rails.root.join("config/storage.yml"))
|
configs = Rails.configuration.active_storage.service_configurations ||= begin
|
||||||
raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
|
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 "yaml"
|
||||||
require "erb"
|
require "erb"
|
||||||
|
|
||||||
YAML.load(ERB.new(config_file.read).result) || {}
|
YAML.load(ERB.new(config_file.read).result) || {}
|
||||||
rescue Psych::SyntaxError => e
|
rescue Psych::SyntaxError => e
|
||||||
raise "YAML syntax error occurred while parsing #{config_file}. " \
|
raise "YAML syntax error occurred while parsing #{config_file}. " \
|
||||||
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
||||||
"Error: #{e.message}"
|
"Error: #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if global_service_name = app.config.active_storage.service
|
ActiveStorage::Blob.service =
|
||||||
ActiveStorage.service =
|
|
||||||
begin
|
begin
|
||||||
ActiveStorage::Service.configure(global_service_name)
|
ActiveStorage::Service.configure config_choice, configs
|
||||||
rescue => e
|
rescue => e
|
||||||
raise e, "Cannot load `Rails.config.active_storage.service`:\n#{e.message}", e.backtrace
|
raise e, "Cannot load `Rails.config.active_storage.service`:\n#{e.message}", e.backtrace
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,7 +45,7 @@ module ActiveStorage
|
||||||
# Configure an Active Storage service by name from a set of configurations,
|
# Configure an Active Storage service by name from a set of configurations,
|
||||||
# typically loaded from a YAML file. The Active Storage engine uses this
|
# typically loaded from a YAML file. The Active Storage engine uses this
|
||||||
# to set the global Active Storage service when the app boots.
|
# 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)
|
Configurator.build(service_name, configurations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue