Skip to content

StorageInstance

StorageInstance<T> = object

Defined in: packages/storage/src/types.ts:346

T extends StorageSchema

clientConfig: () => ClientStorageConfig

Defined in: packages/storage/src/types.ts:398

Extract the client-safe subset of the schema for use with StorageProvider.

ClientStorageConfig


getPublicUrl: (name, key) => string

Defined in: packages/storage/src/types.ts:370

Build a public URL for a file in a public bucket.

keyof T & string

string

string


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.

keyof T & string

string

SignedUrlOptions

Promise<string>


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:

  1. handle(name, request, ctx) — pass the raw Request; the handler will parse the multipart body itself. Use this when the request body contains only the file.
  2. handle(name, file, ctx) — pass a pre-extracted File object. Use this when the request body carries the file alongside structured fields (e.g. a title) that you need to read too — parse formData() once, then hand the File to this overload.

K extends keyof T & string

K

Request | File

HandleContext<T[K] extends FiletypeConfig<infer I> ? I : Record<string, unknown>>

Promise<UploadResult>


schema: T

Defined in: packages/storage/src/types.ts:348

The raw schema passed to defineStorage.


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.

keyof T & string

string

ServeOptions

Promise<Response>


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.

string

InstanceSignedUrlOptions

Promise<string>


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.

string

string

Record<string, unknown>

Promise<boolean>

true when the token is well-formed, unexpired, and the HMAC matches the key; false otherwise.


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.

string

Record<string, unknown>

Promise<boolean>