diff --git a/src/content/docs/r2/api/workers/workers-api-reference.mdx b/src/content/docs/r2/api/workers/workers-api-reference.mdx
index 98ed83803a74eb6..274180efe2c5dcc 100644
--- a/src/content/docs/r2/api/workers/workers-api-reference.mdx
+++ b/src/content/docs/r2/api/workers/workers-api-reference.mdx
@@ -3,6 +3,7 @@ pcx_content_type: reference
title: Workers API reference
---
+import { Type, MetaInfo } from "~/components";
The in-Worker R2 API is accessed by binding an R2 bucket to a [Worker](/workers). The Worker you write can expose external access to buckets via a route or manipulate R2 objects internally.
@@ -63,41 +64,39 @@ export default {
};
```
-
-
-* head(keystring)
: Promise\
+* `head`
* Retrieves the `R2Object` for the given key containing only object metadata, if the key exists, and `null` if the key does not exist.
-* get(keystring, optionsR2GetOptionsoptional)
: Promise\
+* `get`
* Retrieves the `R2ObjectBody` for the given key containing object metadata and the object body as a ReadableStream
, if the key exists, and `null` if the key does not exist.
* In the event that a precondition specified in options
fails, get()
returns an R2Object
with body
undefined.
-* put(keystring, valueReadableStream|ArrayBuffer|ArrayBufferView|string|null|Blob,
optionsR2PutOptionsoptional)
: Promise\
+* `put`
* Stores the given value
and metadata under the associated key
. Once the write succeeds, returns an `R2Object` containing metadata about the stored Object.
* In the event that a precondition specified in options
fails, put()
returns `null`, and the object will not be stored.
* R2 writes are strongly consistent. Once the Promise resolves, all subsequent read operations will see this key value pair globally.
-* delete(keysstring | string\[])
: Promise\
+* `delete`
* Deletes the given values
and metadata under the associated keys
. Once the delete succeeds, returns void
.
* R2 deletes are strongly consistent. Once the Promise resolves, all subsequent read operations will no longer see the provided key value pairs globally.
-* list(optionsR2ListOptionsoptional)
: Promise\
+* `list`
* Returns an R2Objects
containing a list of R2Object
contained within the bucket.
* The returned list of objects is ordered lexicographically.
* Returns up to 1000 entries, but may return less in order to minimize memory pressure within the Worker.
* To explicitly set the number of objects to list, provide an [R2ListOptions](/r2/api/workers/workers-api-reference/#r2listoptions) object with the `limit` property set.
-* createMultipartUpload(keystring, optionsR2MultipartOptions)
: Promise\
+* `createMultipartUpload`
* Creates a multipart upload.
* Returns Promise which resolves to an `R2MultipartUpload` object representing the newly created multipart upload. Once the multipart upload has been created, the multipart upload can be immediately interacted with globally, either through the Workers API, or through the S3 API.
-* resumeMultipartUpload(keystring, uploadIdstring)
: R2MultipartUpload
+* `resumeMultipartUpload`
* Returns an object representing a multipart upload with the given key and uploadId.
* The resumeMultipartUpload operation does not perform any checks to ensure the validity of the uploadId, nor does it verify the existence of a corresponding active multipart upload. This is done to minimize latency before being able to call subsequent operations on the `R2MultipartUpload` object.
@@ -110,19 +109,19 @@ export default {
-* key
string
+* `key`
* The object's key.
-* version
string
+* `version`
* Random unique string associated with a specific upload of a key.
-* size
number
+* `size`
* Size of the object in bytes.
-* etag
string
+* `etag`
:::note
@@ -131,35 +130,35 @@ Cloudflare recommends using the `httpEtag` field when returning an etag in a res
* The etag associated with the object upload.
-* httpEtag
string
+* `httpEtag`
* The object's etag, in quotes so as to be returned as a header.
-* uploaded
Date
+* `uploaded`
* A Date object representing the time the object was uploaded.
-* httpMetadata
R2HTTPMetadata
+* `httpMetadata`
* Various HTTP headers associated with the object. Refer to [HTTP Metadata](#http-metadata).
-* customMetadata
Record\
+* `customMetadata`
* A map of custom, user-defined metadata associated with the object.
-* range
R2Range
+* `range`
* A `R2Range` object containing the returned range of the object.
-* checksums
R2Checksums
+* `checksums`
* A `R2Checksums` object containing the stored checksums of the object. Refer to [checksums](#checksums).
-* writeHttpMetadata(headersHeaders)
: void
+* `writeHttpMetadata`
* Retrieves the `httpMetadata` from the `R2Object` and applies their corresponding HTTP headers to the `Headers` input object. Refer to [HTTP Metadata](#http-metadata).
-* storageClass
"Standard"|"InfrequentAccess"
+* `storageClass`
* The storage class associated with the object. Refer to [Storage Classes](#storage-class).
@@ -171,27 +170,27 @@ Cloudflare recommends using the `httpEtag` field when returning an etag in a res
-* body
ReadableStream
+* `body`
* The object's value.
-* bodyUsed
boolean
+* `bodyUsed`
* Whether the object's value has been consumed or not.
-* arrayBuffer()
: Promise\
+* `arrayBuffer`
* Returns a Promise that resolves to an `ArrayBuffer` containing the object's value.
-* text()
: Promise\
+* `text`
* Returns a Promise that resolves to an string containing the object's value.
-* json``()
: Promise\
+* `json`
* Returns a Promise that resolves to the given object containing the object's value.
-* blob()
: Promise\
+* `blob`
* Returns a Promise that resolves to a binary Blob containing the object's value.
@@ -215,24 +214,24 @@ A multipart upload can be completed or aborted at any time, either through the S
-* key
string
+* `key`
* The `key` for the multipart upload.
-* uploadId
string
+* `uploadId`
* The `uploadId` for the multipart upload.
-* uploadPart(partNumbernumber, valueReadableStream|ArrayBuffer|ArrayBufferView|string|Blob)
: Promise\
+* `uploadPart`
* Uploads a single part with the specified part number to this multipart upload. Each part must be uniform in size with an exception for the final part which can be smaller.
* Returns an `R2UploadedPart` object containing the `etag` and `partNumber`. These `R2UploadedPart` objects are required when completing the multipart upload.
-* abort()
: Promise\
+* `abort`
* Aborts the multipart upload. Returns a Promise that resolves when the upload has been successfully aborted.
-* complete(uploadedPartsR2UploadedPart\[])
: Promise\
+* `complete`
* Completes the multipart upload with the given parts.
* Returns a Promise that resolves when the complete operation has finished. Once this happens, the object is immediately accessible globally by any subsequent read operation.
@@ -245,10 +244,10 @@ A multipart upload can be completed or aborted at any time, either through the S
-* onlyIf
R2Conditional |Headers
+* `onlyIf`
* Specifies that the object should only be returned given satisfaction of certain conditions in the `R2Conditional` or in the conditional Headers. Refer to [Conditional operations](#conditional-operations).
-* range
R2Range
+* `range`
* Specifies that only a specific length (from an optional offset) or suffix of bytes from the object should be returned. Refer to [Ranged reads](#ranged-reads).
@@ -266,15 +265,15 @@ There are 3 variations of arguments that can be used in a range:
-* offset
number
+* `offset`
* The byte to begin returning data from, inclusive.
-* length
number
+* `length`
* The number of bytes to return. If more bytes are requested than exist in the object, fewer bytes than this number may be returned.
-* suffix
number
+* `suffix`
* The number of bytes to return from the end of the file, starting from the last byte. If more bytes are requested than exist in the object, fewer bytes than this number may be returned.
@@ -284,15 +283,15 @@ There are 3 variations of arguments that can be used in a range:
-* onlyIf
R2Conditional |Headers
+* `onlyIf`
* Specifies that the object should only be stored given satisfaction of certain conditions in the `R2Conditional`. Refer to [Conditional operations](#conditional-operations).
-* httpMetadata
R2HTTPMetadata |Headersoptional
+* `httpMetadata`
* Various HTTP headers associated with the object. Refer to [HTTP Metadata](#http-metadata).
-* customMetadata
Record\optional
+* `customMetadata`
* A map of custom, user-defined metadata that will be stored with the object.
@@ -304,27 +303,27 @@ Only a single hashing algorithm can be specified at once.
:::
-* md5
ArrayBuffer |stringoptional
+* `md5`
* A md5 hash to use to check the received object's integrity.
-* sha1
ArrayBuffer |stringoptional
+* `sha1`
* A SHA-1 hash to use to check the received object's integrity.
-* sha256
ArrayBuffer |stringoptional
+* `sha256`
* A SHA-256 hash to use to check the received object's integrity.
-* sha384
ArrayBuffer |stringoptional
+* `sha384`
* A SHA-384 hash to use to check the received object's integrity.
-* sha512
ArrayBuffer |stringoptional
+* `sha512`
* A SHA-512 hash to use to check the received object's integrity.
-* storageClass
"Standard"|"InfrequentAccess"
+* `storageClass`
* Sets the storage class of the object if provided. Otherwise, the object will be stored in the default storage class associated with the bucket. Refer to [Storage Classes](#storage-class).
@@ -334,15 +333,15 @@ Only a single hashing algorithm can be specified at once.
-* httpMetadata
R2HTTPMetadata |Headersoptional
+* `httpMetadata`
* Various HTTP headers associated with the object. Refer to [HTTP Metadata](#http-metadata).
-* customMetadata
Record\optional
+* `customMetadata`
* A map of custom, user-defined metadata that will be stored with the object.
-* storageClass
string
+* `storageClass`
* Sets the storage class of the object if provided. Otherwise, the object will be stored in the default storage class associated with the bucket. Refer to [Storage Classes](#storage-class).
@@ -352,21 +351,21 @@ Only a single hashing algorithm can be specified at once.
-* limit
numberoptional
+* `limit`
* The number of results to return. Defaults to `1000`, with a maximum of `1000`.
* If `include` is set, you may receive fewer than `limit` results in your response to accommodate metadata.
-* prefix
stringoptional
+* `prefix`
* The prefix to match keys against. Keys will only be returned if they start with given prefix.
-* cursor
stringoptional
+* `cursor`
* An opaque token that indicates where to continue listing objects from. A cursor can be retrieved from a previous list operation.
-* delimiter
stringoptional
+* `delimiter`
* The character to use when grouping keys.
-* include
Array\optional
+* `include`
* Can include `httpMetadata` and/or `customMetadata`. If included, items returned by the list will include the specified metadata.
@@ -415,19 +414,19 @@ An object containing an `R2Object` array, returned by `BUCKET_BINDING.list()`.
-* objects
Array\
+* `objects`
* An array of objects matching the `list` request.
-* truncated
boolean
+* `truncated` boolean
* If true, indicates there are more results to be retrieved for the current `list` request.
-* cursor
stringoptional
+* `cursor`
* A token that can be passed to future `list` calls to resume listing from that point. Only present if truncated is true.
-* delimitedPrefixes
Array\
+* `delimitedPrefixes`
* If a delimiter has been specified, contains all prefixes between the specified prefix and the next occurrence of the delimiter.
@@ -443,19 +442,19 @@ If the condition check for `put()` fails, `null` will be returned instead of the
-* etagMatches
stringoptional
+* `etagMatches`
* Performs the operation if the object's etag matches the given string.
-* etagDoesNotMatch
stringoptional
+* `etagDoesNotMatch`
* Performs the operation if the object's etag does not match the given string.
-* uploadedBefore
Dateoptional
+* `uploadedBefore`
* Performs the operation if the object was uploaded before the given date.
-* uploadedAfter
Dateoptional
+* `uploadedAfter`
* Performs the operation if the object was uploaded after the given date.
@@ -471,17 +470,17 @@ Generally, these fields match the HTTP metadata passed when the object was creat
-* contentType
stringoptional
+* `contentType`
-* contentLanguage
stringoptional
+* `contentLanguage`
-* contentDisposition
stringoptional
+* `contentDisposition`
-* contentEncoding
stringoptional
+* `contentEncoding`
-* cacheControl
stringoptional
+* `cacheControl`
-* cacheExpiry
Dateoptional
+* `cacheExpiry`
@@ -491,23 +490,23 @@ If a checksum was provided when using the `put()` binding, it will be available
-* md5
ArrayBuffer optional
+* `md5`
* The MD5 checksum of the object.
-* sha1
ArrayBuffer optional
+* `sha1`
* The SHA-1 checksum of the object.
-* sha256
ArrayBuffer optional
+* `sha256`
* The SHA-256 checksum of the object.
-* sha384
ArrayBuffer optional
+* `sha384`
* The SHA-384 checksum of the object.
-* sha512
ArrayBuffer optional
+* `sha512`
* The SHA-512 checksum of the object.
@@ -519,11 +518,11 @@ An `R2UploadedPart` object represents a part that has been uploaded. `R2Uploaded
-* partNumber
number
+* `partNumber`
* The number of the part.
-* etag
string
+* `etag`
* The `etag` of the part.