Adds support for proxying Active Storage blobs (to serve them via CDN).
Based on rails/rails#34477.
To serve a blob via proxy use generate the URL using the following url helper
rails_proxy_blob_url(signed_id: attachment.signed_id, filename: attachment.filename)
# and for variants
variant = attachment.variant(:medium)
rails_proxy_blob_url(signed_id: attachment.signed_id, variation_key: variant.variation.key, filename: variant.filename)
You can configure the cache headers:
# config/environments/production.rb
# Default values are
config.active_storage_proxy.proxy_urls_expire_in = 1.year
config.active_storage_proxy.proxy_urls_public = true
Hi! This seems what I'm looking for until Rails has something built in to allow for usa with CDNs. Question: which syntax should I use to generate a variant with e.g. resize_to_limit and similar? Thanks