mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
add blobs proxy controller
This commit is contained in:
1 parent
5a3174a720
commit
a728aa8689
8 files changed
+49
-7
No files matched your search
@@ -14,13 +14,20 @@ ActiveSupport.on_load(:active_storage_attachment) do
|
||||
|
||||
return unless first_page
|
||||
|
||||
Rails.application.routes.url_helpers.rails_storage_proxy_url(first_page, **Docuseal.default_url_options)
|
||||
ActiveStorage::Blob.proxy_url(first_page.blob)
|
||||
end
|
||||
end
|
||||
|
||||
ActiveSupport.on_load(:active_storage_blob) do
|
||||
attribute :uuid, :string, default: -> { SecureRandom.uuid }
|
||||
|
||||
def self.proxy_url(blob, expires_in: nil)
|
||||
Rails.application.routes.url_helpers.blobs_proxy_url(
|
||||
signed_uuid: blob.signed_uuid(expires_in:), filename: blob.filename,
|
||||
**Docuseal.default_url_options
|
||||
)
|
||||
end
|
||||
|
||||
def uuid
|
||||
super || begin
|
||||
new_uuid = SecureRandom.uuid
|
||||
@@ -29,6 +36,10 @@ ActiveSupport.on_load(:active_storage_blob) do
|
||||
end
|
||||
end
|
||||
|
||||
def signed_uuid(expires_in: nil)
|
||||
ApplicationRecord.signed_id_verifier.generate(uuid, expires_in:)
|
||||
end
|
||||
|
||||
def delete
|
||||
service.delete(key)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user