Skip to content

R2 storage backends

An OpenFlare R2 bucket is backed by one of two kinds of storage. You choose when you create the bucket.

Backend What it is How you select it
Cell default (local Silo) Objects are stored by the cell’s own storage service. No external account is needed. Omit backend in the API, or choose Cell default in the console.
Proxy to Cloudflare R2 The bucket is a prefix inside a bucket on Cloudflare R2, reached over its S3 API. backend.type = "cloudflare-r2"
Proxy to Amazon S3 The bucket is a prefix inside an Amazon S3 bucket. backend.type = "s3"

From a worker the bucket is always used the same way, through an [[r2_buckets]] binding. See Bindings.

Terminal window
of r2 bucket create my-bucket

You can also use the console (Storage & Databases > R2 Object Storage) or the API:

Terminal window
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \
$PLANE/api/v1/cells/$CELL/r2/buckets \
-d '{"teamId":"'$TEAM'","bucketName":"my-bucket"}'

In the console, open the R2 page, create a bucket, and set Backend to Cloudflare R2 or Amazon S3. Over the API, add a backend object. The request body is strict, so unknown fields are rejected.

Terminal window
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \
$PLANE/api/v1/cells/$CELL/r2/buckets \
-d '{
"teamId": "'$TEAM'",
"bucketName": "uploads",
"backend": {
"type": "s3",
"bucket": "my-aws-bucket",
"region": "us-east-1",
"prefix": "openflare/uploads/",
"credentials": {"accessKeyId": "AKIA...", "secretAccessKey": "..."}
}
}'

Replace region with accountId and, optionally, jurisdiction:

{
"type": "cloudflare-r2",
"bucket": "my-r2-bucket",
"accountId": "0123456789abcdef0123456789abcdef",
"jurisdiction": "eu",
"credentials": {"accessKeyId": "...", "secretAccessKey": "..."}
}
Field Applies to Rules
type both cloudflare-r2 or s3.
bucket both The remote bucket name, 3 to 63 characters, a valid bucket name.
prefix both Optional. 1 to 512 characters, made of path segments each ending in / (for example openflare/uploads/). If omitted, OpenFlare generates openflare/<bucket id>/.
credentials.accessKeyId both 1 to 256 characters.
credentials.secretAccessKey both 1 to 1024 characters. Stored encrypted by the plane.
accountId cloudflare-r2 32 lowercase hex characters.
jurisdiction cloudflare-r2 default (the default), eu, fedramp or us.
region s3 An AWS region such as us-east-1. Regions starting with cn- and us-gov- map to the AWS China and GovCloud partitions.

Each logical bucket owns its prefix in the remote bucket. Give different OpenFlare buckets non-overlapping prefixes.

POST /api/v1/cells/{cell}/r2/backend-tests checks credentials and reachability without creating a bucket.

Terminal window
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \
$PLANE/api/v1/cells/$CELL/r2/backend-tests \
-d '{"teamId":"'$TEAM'","backend":{...},"writeTest":true}'
# 202 {"data":{"opId":"...","prefix":"..."}}

writeTest (default false) additionally writes and removes a probe object. In the console this is the Test write and cleanup checkbox. Poll the result with GET /api/v1/cells/{cell}/ops/{opId}?waitMs=10000.

GET /api/v1/cells/{cell}/r2/buckets?teamId=... returns each bucket with backend, backend_state, last_probe and checked_at. A proxy bucket shows pending until its first successful probe, and detaching while it is being detached. In the console, the bucket row shows the backend type, bucket/prefix, the state and the last probe result.

Retest a bucket with an empty body:

Terminal window
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \
$PLANE/api/v1/cells/$CELL/r2/buckets/uploads/probe -d '{}'
# 202 {"data":{"queued":true,"opId":"..."}}

The console row menu offers Test connection and Rotate credentials for proxy buckets.

Send new credentials to the probe route. The plane holds them as pending credentials and queues a probe; a probe that carries credentials also performs a write test.

Terminal window
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \
$PLANE/api/v1/cells/$CELL/r2/buckets/uploads/probe \
-d '{"credentials":{"accessKeyId":"...","secretAccessKey":"..."}}'

DELETE /api/v1/cells/{cell}/r2/buckets/{name}:

  • Returns 409 while an active version of any worker in the team still references the bucket. Remove the binding and deploy first.
  • For a connected proxy bucket, returns 202 with an opId and the channel cell. Follow it with GET .../ops/{opId}.
  • For a bucket that was never connected, the record is deleted immediately.

In the console the action is labelled Detach for proxy buckets and Delete for the others.

Detaching removes OpenFlare’s mapping only. It does not delete the objects in the remote bucket.

Consideration Local Silo Proxy
External account None Needed, with an access key pair
Data lives In the cell’s storage In your Cloudflare R2 or Amazon S3 bucket
Conditional requests (onlyIf) Depend on the storage backend Depend on the provider’s s3.conditionalWrites support; test with your provider
SSE-C Not available S3 backend only
Build requirement Public release images A build that includes proxy backends
  • Control-plane object operations (of r2 object ... and the console object browser) cap an object at 4 MiB, and the plane’s JSON request limit makes the practical size smaller. Use the binding from a worker for larger objects.
  • jurisdiction and storage_class in a worker’s wrangler config are rejected. The jurisdiction above belongs to the backend, not the worker config.

Bindings, Management API, Console, CLI reference, Limits.