I haven’t tried this myself, but in 6.1 you can use the proxy I think. This doesn’t answer your question directly, but maybe helpful:
Put this into routes:
direct :cdn_proxy do |model, options|
if model.respond_to?(:signed_id)
route_for(
:rails_service_blob_proxy,
model.signed_id,
model.filename,
options.merge(host: Settings.asset_host)
)
else
signed_blob_id = model.blob.signed_id
variation_key = model.variation.key
filename = model.blob.filename
route_for(
:rails_blob_representation_proxy,
signed_blob_id,
variation_key,
filename,
options.merge(host: Settings.asset_host)
)
end
end
Put this into your environment files:
config.active_storage.resolve_model_to_route = :cdn_proxy
You can call the images as:
rails_storage_proxy_url # for the main attachments
rails_blob_representation_proxy_url # for the variants
Credit: Vito Botta