StorageInstance
StorageInstance<
T> =object
Defined in: packages/storage/src/types.ts:346
Type Parameters
Section titled “Type Parameters”T extends StorageSchema
Properties
Section titled “Properties”clientConfig()
Section titled “clientConfig()”clientConfig: () =>
ClientStorageConfig
Defined in: packages/storage/src/types.ts:398
Extract the client-safe subset of the schema for use with StorageProvider.
Returns
Section titled “Returns”getPublicUrl()
Section titled “getPublicUrl()”getPublicUrl: (
name,key) =>string
Defined in: packages/storage/src/types.ts:370
Build a public URL for a file in a public bucket.
Parameters
Section titled “Parameters”keyof T & string
string
Returns
Section titled “Returns”string
getSignedUrl()
Section titled “getSignedUrl()”getSignedUrl: (
name,key,options) =>Promise<string>
Defined in: packages/storage/src/types.ts:372
Generate a time-limited HMAC-signed URL for private file access, scoped to a filetype.
Parameters
Section titled “Parameters”keyof T & string
string
options
Section titled “options”Returns
Section titled “Returns”Promise<string>
handle()
Section titled “handle()”handle: <
K>(name,source,ctx) =>Promise<UploadResult>
Defined in: packages/storage/src/types.ts:362
Parse, validate, and upload a file to R2.
Two forms are supported:
handle(name, request, ctx)— pass the rawRequest; the handler will parse the multipart body itself. Use this when the request body contains only the file.handle(name, file, ctx)— pass a pre-extractedFileobject. Use this when the request body carries the file alongside structured fields (e.g. a title) that you need to read too — parseformData()once, then hand theFileto this overload.
Type Parameters
Section titled “Type Parameters”K extends keyof T & string
Parameters
Section titled “Parameters”K
source
Section titled “source”Request | File
HandleContext<T[K] extends FiletypeConfig<infer I> ? I : Record<string, unknown>>
Returns
Section titled “Returns”Promise<UploadResult>
schema
Section titled “schema”schema:
T
Defined in: packages/storage/src/types.ts:348
The raw schema passed to defineStorage.
serve()
Section titled “serve()”serve: (
name,key,options) =>Promise<Response>
Defined in: packages/storage/src/types.ts:368
Stream a file directly from R2, returning a Response with appropriate headers.
Parameters
Section titled “Parameters”keyof T & string
string
options
Section titled “options”Returns
Section titled “Returns”Promise<Response>
signedUrl()
Section titled “signedUrl()”signedUrl: (
key,options) =>Promise<string>
Defined in: packages/storage/src/types.ts:385
Mint a short, time-limited URL pointing at the /uploads/* proxy route
for private file access. The returned path is relative (e.g.
/uploads/products/abc/image.jpg?token=...) and its token is validated
by the proxy route before streaming the underlying R2 object.
Unlike getSignedUrl, this helper is not scoped to a filetype —
the token binds the key and expiry only, which is what the opinionated
/uploads/* proxy route expects.
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”Promise<string>
verifySignedToken()
Section titled “verifySignedToken()”verifySignedToken: (
key,token,options) =>Promise<boolean>
Defined in: packages/storage/src/types.ts:392
Verify a token minted by signedUrl against a raw R2 object key.
Parameters
Section titled “Parameters”string
string
options
Section titled “options”Record<string, unknown>
Returns
Section titled “Returns”Promise<boolean>
true when the token is well-formed, unexpired, and the HMAC
matches the key; false otherwise.
verifySignedUrl()
Section titled “verifySignedUrl()”verifySignedUrl: (
url,options) =>Promise<boolean>
Defined in: packages/storage/src/types.ts:374
Verify that a (filetype-scoped) signed URL has a valid signature and has not expired.
Parameters
Section titled “Parameters”string
options
Section titled “options”Record<string, unknown>
Returns
Section titled “Returns”Promise<boolean>