Skip to content
Start here

Objects

List Objects
client.r2.buckets.objects.list(stringbucketName, ObjectListParams { account_id, cursor, delimiter, 4 more } params, RequestOptionsoptions?): CursorPagination<ObjectListResponse { custom_metadata, etag, http_metadata, 5 more } >
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects
Get Object
client.r2.buckets.objects.get(stringbucketName, stringobjectKey, ObjectGetParams { account_id, jurisdiction, ifModifiedSince, ifNoneMatch } params, RequestOptionsoptions?): Response
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Upload Object
client.r2.buckets.objects.upload(stringbucketName, stringobjectKey, "string" | "ArrayBufferView" | "ArrayBuffer" | BlobLikebody, ObjectUploadParams { account_id, jurisdiction, cfR2StorageClass } params, RequestOptionsoptions?): ObjectUploadResponse { etag, key, size, 3 more }
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Delete Object
client.r2.buckets.objects.delete(stringbucketName, stringobjectKey, ObjectDeleteParams { account_id, jurisdiction } params, RequestOptionsoptions?): ObjectDeleteResponse { key }
DELETE/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
ModelsExpand Collapse
ObjectListResponse { custom_metadata, etag, http_metadata, 5 more }

Metadata for an R2 object.

custom_metadata?: Record<string, string>

Custom metadata key-value pairs associated with the object.

etag?: string

The entity tag for the object. In JSON list/get responses this is the raw hex digest (without surrounding quotes). The HTTP ETag response header on Get Object follows RFC 7232 and IS wrapped in surrounding double-quotes.

http_metadata?: HTTPMetadata { cacheControl, cacheExpiry, contentDisposition, 3 more }

HTTP metadata associated with an R2 object.

cacheControl?: string

Specifies caching behavior for the object.

cacheExpiry?: string

The date and time at which the object’s cache entry expires.

formatdate-time
contentDisposition?: string

Specifies presentational information for the object.

contentEncoding?: string

Specifies the content encoding applied to the object.

contentLanguage?: string

The language of the object content.

contentType?: string

The MIME type of the object.

key?: string

The object key (name).

last_modified?: string

The date and time the object was last modified.

formatdate-time
size?: number

The size of the object in bytes.

ssec?: boolean

Whether the object is encrypted with a customer-supplied encryption key.

storage_class?: "Standard" | "InfrequentAccess"

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"
ObjectUploadResponse { etag, key, size, 3 more }

Result of a successful object upload.

etag?: string

The entity tag for the uploaded object.

key?: string

The key (name) of the uploaded object.

size?: string

The size of the uploaded object in bytes (as a string).

storage_class?: "Standard" | "InfrequentAccess"

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"
uploaded?: string

The date and time the object was uploaded.

formatdate-time
version?: string

The version UUID of the uploaded object.

ObjectDeleteResponse { key }

Result of a successful object deletion.

key?: string

The key (name) of the deleted object.