Class: Collavre::PublicAssetsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Collavre::PublicAssetsController
- Includes:
- ActiveStorage::SetCurrent, ActiveStorage::Streaming
- Defined in:
- app/controllers/collavre/public_assets_controller.rb
Overview
Serves ActiveStorage blobs through a CDN-friendly path:
/public-assets/blobs/:signed_id/*filename
The signed_id is the only capability — no auth required. This makes the URL safe to embed in landing pages and other publicly-rendered HTML. CloudFront caches by full URL, so rotating signed_id (re-attach) invalidates effectively.
Constant Summary collapse
- PUBLIC_CACHE_CONTROL =
"public, max-age=31536000, immutable"
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/controllers/collavre/public_assets_controller.rb', line 16 def show blob = ActiveStorage::Blob.find_signed!(params[:signed_id]) response.headers["Cache-Control"] = PUBLIC_CACHE_CONTROL send_blob_stream blob, disposition: "inline" rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveRecord::RecordNotFound head :not_found end |