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.
Create a bucket on the local backend
Section titled “Create a bucket on the local backend”of r2 bucket create my-bucketYou can also use the console (Storage & Databases > R2 Object Storage) or the API:
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \ $PLANE/api/v1/cells/$CELL/r2/buckets \ -d '{"teamId":"'$TEAM'","bucketName":"my-bucket"}'Create a proxy bucket
Section titled “Create a proxy 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.
Amazon S3
Section titled “Amazon S3”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": "..."} } }'Cloudflare R2
Section titled “Cloudflare R2”Replace region with accountId and, optionally, jurisdiction:
{ "type": "cloudflare-r2", "bucket": "my-r2-bucket", "accountId": "0123456789abcdef0123456789abcdef", "jurisdiction": "eu", "credentials": {"accessKeyId": "...", "secretAccessKey": "..."}}Backend fields
Section titled “Backend fields”| 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.
Test the connection before you create
Section titled “Test the connection before you create”POST /api/v1/cells/{cell}/r2/backend-tests checks credentials and reachability without creating a bucket.
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.
Check state and retest
Section titled “Check state and retest”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:
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.
Rotate credentials
Section titled “Rotate credentials”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.
curl -sS -X POST -H "$AUTH" -H 'Content-Type: application/json' \ $PLANE/api/v1/cells/$CELL/r2/buckets/uploads/probe \ -d '{"credentials":{"accessKeyId":"...","secretAccessKey":"..."}}'Detach or delete
Section titled “Detach or delete”DELETE /api/v1/cells/{cell}/r2/buckets/{name}:
- Returns
409while 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
202with anopIdand the channelcell. Follow it withGET .../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.
Choosing a backend
Section titled “Choosing a backend”| 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 |
Limits that apply to both
Section titled “Limits that apply to both”- 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. jurisdictionandstorage_classin a worker’s wrangler config are rejected. Thejurisdictionabove belongs to the backend, not the worker config.