Skip to content
Start here

Objects

List Objects
r2.buckets.objects.list(strbucket_name, ObjectListParams**kwargs) -> SyncCursorPagination[ObjectListResponse]
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects
Get Object
r2.buckets.objects.get(strobject_key, ObjectGetParams**kwargs) -> BinaryResponseContent
GET/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Upload Object
r2.buckets.objects.upload(strobject_key, objectbody, ObjectUploadParams**kwargs) -> ObjectUploadResponse
PUT/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Delete Object
r2.buckets.objects.delete(strobject_key, ObjectDeleteParams**kwargs) -> ObjectDeleteResponse
DELETE/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
ModelsExpand Collapse
class ObjectListResponse:

Metadata for an R2 object.

custom_metadata: Optional[Dict[str, str]]

Custom metadata key-value pairs associated with the object.

etag: Optional[str]

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: Optional[HTTPMetadata]

HTTP metadata associated with an R2 object.

cache_control: Optional[str]

Specifies caching behavior for the object.

cache_expiry: Optional[datetime]

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

formatdate-time
content_disposition: Optional[str]

Specifies presentational information for the object.

content_encoding: Optional[str]

Specifies the content encoding applied to the object.

content_language: Optional[str]

The language of the object content.

content_type: Optional[str]

The MIME type of the object.

key: Optional[str]

The object key (name).

last_modified: Optional[datetime]

The date and time the object was last modified.

formatdate-time
size: Optional[int]

The size of the object in bytes.

ssec: Optional[bool]

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

storage_class: Optional[Literal["Standard", "InfrequentAccess"]]

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"
class ObjectUploadResponse:

Result of a successful object upload.

etag: Optional[str]

The entity tag for the uploaded object.

key: Optional[str]

The key (name) of the uploaded object.

size: Optional[str]

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

storage_class: Optional[Literal["Standard", "InfrequentAccess"]]

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"
uploaded: Optional[datetime]

The date and time the object was uploaded.

formatdate-time
version: Optional[str]

The version UUID of the uploaded object.

class ObjectDeleteResponse:

Result of a successful object deletion.

key: Optional[str]

The key (name) of the deleted object.