class MartenRailsBridge::ActiveStorage::DiskHandler

Overview

Serves blobs stored with the Disk service, through an expiring signed key.

Mount it on the route Rails uses, so that URLs issued by a Rails app keep resolving (Rails names this route rails_disk_service):

path "/rails/active_storage/disk/<encoded_key:str>/<filename:path>",
  MartenRailsBridge::ActiveStorage::DiskHandler,
  name: "active_storage_disk"

The filename route parameter only shapes the URL: the content type and the disposition served to the client come from the encoded key. https://github.com/rails/rails/blob/v8.1.3/activestorage/app/controllers/active_storage/disk_controller.rb

Defined in:

active_storage/disk_handler.cr

Constant Summary

CHUNK_SIZE = 8192

Size of the chunks the file is streamed in, matching Rack::Files.

DEFAULT_SEND_FILE_DISPOSITION = "attachment"

Disposition served when the encoded key carries none (ActionController::DataStreaming::DEFAULT_SEND_FILE_DISPOSITION).

DEFAULT_SEND_FILE_TYPE = "application/octet-stream"

Content type served when the encoded key carries none (ActionController::DataStreaming::DEFAULT_SEND_FILE_TYPE). https://github.com/rails/rails/blob/v8.1.3/actionpack/lib/action_controller/metal/data_streaming.rb

RANGE_NOT_SATISFIABLE_BODY = "Byte range unsatisfiable\n"

Body Rack::Files serves when a Range header cannot be satisfied.

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.