createStorageRouteHandlers
createStorageRouteHandlers<
T>(options):object
Defined in: packages/storage/src/route-handlers.ts:148
Build loader and action handlers for the /uploads/* route.
The returned pair implements the full opinionated upload + proxy story:
loader(GET requests) — streams the R2 object whose key matchesparams["*"]. If the storage definition declares anownerCheckfor the owning filetype, the check is invoked before streaming and a 403 response is returned on failure. If the URL carries?token=..., the token is verified againstSTORAGE_SECRETinstead of runningownerCheck(so tokens can be shared without exposing the underlying auth state).action(POST requests) — treatsparams["*"]as a filetype name, callsstorage.handle(name, request, ctx), and returns a JSON body of UploadRouteResult.
Type Parameters
Section titled “Type Parameters”T extends StorageSchema
Parameters
Section titled “Parameters”options
Section titled “options”CreateStorageRouteHandlersOptions<T>
Storage instance, auth gate, env resolver, and mount path.
Returns
Section titled “Returns”object
{ loader, action } ready to re-export from a splat route module.
action()
Section titled “action()”action: (
args) =>Promise<Response>
Parameters
Section titled “Parameters”RouteArgs
Returns
Section titled “Returns”Promise<Response>
loader()
Section titled “loader()”loader: (
args) =>Promise<Response>
Parameters
Section titled “Parameters”RouteArgs
Returns
Section titled “Returns”Promise<Response>