class MartenRailsBridge::ActiveStorage::Blobs::RedirectHandler

Overview

Turns a signed permanent reference for a blob into an expiring service URL for download.

Mount it on the route Rails uses, so that URLs issued by a Rails app keep resolving:

path "/rails/active_storage/blobs/redirect/<signed_id:str>/<filename:path>",
  MartenRailsBridge::ActiveStorage::Blobs::RedirectHandler,
  name: "active_storage_blob"

The filename route parameter only shapes the URL: the filename served to the client comes from the blob itself.

WARNING like in Rails, this handler is publicly accessible. The signed IDs are hard to guess but permanent by design. https://github.com/rails/rails/blob/v8.1.3/activestorage/app/controllers/active_storage/blobs/redirect_controller.rb

Direct Known Subclasses

Defined in:

active_storage/blobs/redirect_handler.cr

Instance Method Summary

Instance Method Detail

def get #
Description copied from class Marten::Handlers::Base

Handles a GET HTTP request and returns a Marten::HTTP::Response object.

The default implementation will return a 405 (not allowed) response.