adjust for custom domain
This commit is contained in:
@@ -10,6 +10,7 @@ ActiveSupport.on_load(:active_storage_attachment) do
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/BlockLength
|
||||
ActiveSupport.on_load(:active_storage_blob) do
|
||||
attribute :uuid, :string, default: -> { SecureRandom.uuid }
|
||||
attribute :io_data, :string, default: ''
|
||||
@@ -22,6 +23,12 @@ ActiveSupport.on_load(:active_storage_blob) do
|
||||
)
|
||||
end
|
||||
|
||||
def self.proxy_path(blob, expires_at: nil, filename: nil)
|
||||
Rails.application.routes.url_helpers.blobs_proxy_path(
|
||||
signed_uuid: blob.signed_uuid(expires_at:), filename: filename || blob.filename
|
||||
)
|
||||
end
|
||||
|
||||
def uuid
|
||||
super || begin
|
||||
new_uuid = SecureRandom.uuid
|
||||
@@ -40,6 +47,7 @@ ActiveSupport.on_load(:active_storage_blob) do
|
||||
service.delete(key)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/BlockLength
|
||||
|
||||
ActiveStorage::LogSubscriber.detach_from(:active_storage) if Rails.env.production?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user