The Bucket methods, their TypeScript options and what they return. Each section links to the concept page with the behaviour and defaults.
Building the client is on Overview. Every method runs on your server with the bucket token.
put#
Every option is optional. Behaviour and defaults are on Writing.
| Option | Type | Description |
|---|---|---|
contentType | string | What the object is stored as. |
contentTypes | string[] | An allow list such as ["image/*", "application/pdf"]. See Constraints. |
maxSize | Size | Refuses a larger body with too_large. |
cache | CacheOption | The Cache-Control this object is stored with. See Caching. |
metadata | Record<string, string> | Custom key-value pairs. See Metadata. |
size | number | The exact length in bytes, for a stream whose size is not otherwise known. |
allowOverwrite | boolean | false refuses the write if something is already at the path. See Conditional writes. |
ifUnchanged | string | An etag. The write fails with conflict if the object changed since you read it. |
multipart | boolean | Size | Where a body stops being one PUT. See Large bodies. |
The result is a CompletedBlob:
Bodies#
PutBody is one of these. If the body does not carry its own length or type, declare size or contentType yourself.
| Body | Carries its length | Carries a content type |
|---|---|---|
Request | From its content-length header | From its content-type header |
Blob / File | Yes | Yes, when type is set |
ArrayBuffer | Yes | No |
| Typed array | Yes | No |
string | Yes, once UTF-8 encoded | No |
ReadableStream<Uint8Array> | No | No |
An explicit contentType wins over what the body carries.
A Request with no body, or one that has already been read, throws empty_body. Anything else is a TypeError. A Request that arrived chunked has no content-length and counts as an unknown length, like a stream.
Streams#
A ReadableStream with neither throws length_required. Why is on Streams and unknown lengths.
uniquePath#
Exported from @upstash/blob. The suffix rules are on Unique paths.
updateJson#
| Option | Type | Description |
|---|---|---|
maxAttempts | number | How many read-transform-write rounds to try before throwing conflict. |
cache | CacheOption | The Cache-Control the rewritten object is stored with. |
metadata | Record<string, string> | Replaces the metadata on the object. |
The loop and its defaults are on Updating JSON.
copy and move#
| Option | Type | Description |
|---|---|---|
contentType | string | What the destination is stored as. |
cache | CacheOption | The Cache-Control the destination is stored with. |
metadata | Record<string, string> | Replaces the metadata outright. |
What carries over from the source is on copy and move.
signedUploadUrl#
Returns { url: string, headers: Record<string, string>, expiresAt: Date }. Send headers verbatim.
| Option | Type | Description |
|---|---|---|
expiresIn | Duration | How long the link should live. |
contentType | string | The Content-Type the upload must send, and what the object is stored as. |
cache | CacheOption | The Cache-Control the object is stored with. |
metadata | Record<string, string> | Written as x-amz-meta-*, under the same rules as put. |
size | Size | Pins the body’s exact length. |
allowOverwrite | boolean | false refuses the upload if something is already at the path. |
Defaults and lifetimes are on Signed upload URLs.
get#
body is a ReadableStream<Uint8Array> and nothing is buffered for you. Wrap it in a Response for the usual conversions:
A missing object throws not_found. See get.
info and exists#
list#
Returns { blobs: BlobObject[], cursor: string | undefined }.
| Option | Type | Description |
|---|---|---|
prefix | string | Only keys starting with this. |
limit | number | Page size. |
cursor | string | The cursor from the previous page. |
Defaults and paging are on list.
publicUrl#
undefined on a private bucket. An empty path, or one with a . or .. segment, throws a TypeError. See Public URLs.
signedReadUrl#
Returns { url: string, expiresAt: Date }. Cache the link until expiresAt, never until a deadline you compute from expiresIn.
| Option | Type | Description |
|---|---|---|
expiresIn | Duration | How long to ask for. |
downloadAs | string | Save as this filename instead of displaying inline. |
contentType | string | What storage answers with as Content-Type, overriding what was stored. |
Defaults and lifetimes are on Signed read URLs.
del#
Anything else is refused with invalid_input. A path with a . or .. segment throws a TypeError. What each shape does and throws is on Deleting.
Multipart cleanup#
olderThan is required. See Incomplete multipart uploads.
s3#
A config for @aws-sdk/client-s3. See Using an S3 client.
Records#
Four record types come back from the SDK. They nest. What each field means is on Records.
| Type | Fields | Returned by |
|---|---|---|
BlobObject | path, url?, versionedUrl?, size, etag, uploadedAt | list(), copy(), move(), updateJson() |
CompletedBlob | BlobObject plus contentType | put(), onUploadComplete, a finished browser upload |
BlobInfo | BlobObject plus contentType and metadata | info() |
BlobDownload | BlobInfo plus body: ReadableStream<Uint8Array> | get() |
| Field | Type |
|---|---|
path | string |
url | string | undefined |
versionedUrl | string | undefined |
size | number |
etag | string |
uploadedAt | Date |
contentType | string |
metadata | Record<string, string> |
All four are exported as types from @upstash/blob.