class
MartenRailsBridge::ActiveStorage::Blobs::ProxyHandler
- MartenRailsBridge::ActiveStorage::Blobs::ProxyHandler
- Marten::Handlers::Base
- Reference
- Object
Overview
Streams the bytes of a blob through the app, instead of redirecting to the storage service.
Proxying avoids a redirect and makes a blob easier to cache, since the response can be stored by a CDN sitting in front of the app.
Mount it on the route Rails uses, so that URLs issued by a Rails app keep resolving:
path "/rails/active_storage/blobs/proxy/<signed_id:str>/<filename:path>",
MartenRailsBridge::ActiveStorage::Blobs::ProxyHandler,
name: "active_storage_blob_proxy"
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/proxy_controller.rb
Direct Known Subclasses
- MartenRailsBridge::ActiveStorage::Blobs::ProxyHandlerGuardTest::GuardedHandler
- MartenRailsBridge::ActiveStorage::Blobs::ProxyHandlerGuardTest::WidenedHandler
Defined in:
active_storage/blobs/proxy_handler.crConstant Summary
-
DEFAULT_BLOB_STREAMING_DISPOSITION =
"inline" -
Disposition used when neither the blob nor the request forces one.
https://github.com/rails/rails/blob/v8.1.3/activestorage/app/controllers/concerns/active_storage/streaming.rb
-
DEFAULT_STREAMING_CONTENT_TYPE =
"application/octet-stream" -
Content type used when the blob carries none and none can be guessed from its filename.
https://github.com/rails/rails/blob/v8.1.3/actionpack/lib/action_controller/metal/live.rb
-
HTTP_CACHE_FOREVER_LAST_MODIFIED =
"Sat, 01 Jan 2011 00:00:00 GMT" -
Last-Modifiedofhttp_cache_forever, which Rails pins to 2011-01-01.https://github.com/rails/rails/blob/v8.1.3/actionpack/lib/action_controller/metal/conditional_get.rb
-
HTTP_CACHE_FOREVER_MAX_AGE =
3155695200_i64 -
max-ageofhttp_cache_forever, which is100.yearsin seconds.https://github.com/rails/rails/blob/v8.1.3/actionpack/lib/action_controller/metal/conditional_get.rb
Instance Method Summary
-
#get
Handles a
GETHTTP request and returns aMarten::HTTP::Responseobject.
Instance Method Detail
Handles a GET HTTP request and returns a Marten::HTTP::Response object.
The default implementation will return a 405 (not allowed) response.