Skip to main content
An existing R2 bucket becomes a folder tree, with one file per object.

Setup

R2 signs S3 requests with an R2 API token’s key pair.
  1. In the Cloudflare dashboard, open R2 object storage > Overview.
  2. Under Account Details, pick Manage next to API Tokens, then Create Account API token (or Create User API token).
  3. Under Permissions, choose Object Read only, or Object Read & Write for writes, and scope the token to the bucket.
  4. Create the token and copy the Access Key ID and Secret Access Key. Cloudflare shows the secret only once.
  5. Copy the Account ID from Account Details (it is also in the dashboard URL).
  • The account ID builds the endpoint https://<account-id>.r2.cloudflarestorage.com.
  • A bucket in a jurisdiction has its own endpoint, such as https://<account-id>.eu.r2.cloudflarestorage.com; set endpoint_url (endpoint in TypeScript) to it.

Connect

workspace.yaml

Layout

  • Each object key is a file path; folders are key prefixes, and the bucket holds no directory objects.
  • key_prefix (keyPrefix in TypeScript) mounts one subpath of the bucket as the root.
  • grep -r, find and du stop after 1000 files; a glob matching more, tar -c, cp -r and rm -r are refused.

Sample runs

On a write mount, redirects, cp, mv and rm change objects in the bucket. For write: conditional, see S3-compatible VFSes.

SDK guides

Python

Every config field, the VFS.md and write support.

TypeScript

Every config field, the VFS.md and write support.