Adapter

Cloudflare R2

Overview

Cloudflare R2 speaks S3 but with a few rough edges (no ListObjectVersions, no bucket tagging). The R2 adapter is a thin wrapper over the S3 adapter with R2-friendly defaults: region: 'auto' and an endpoint derived from your account ID.

Snapshots and forks follow the same sibling-bucket pattern as S3; the manifest sits at .storagesdk.metadata.json at the bucket root and is filtered out of list().

Configuration

import { Storage } from '@storagesdk/core';
import { r2 } from '@storagesdk/adapters/r2';

const storage = new Storage({
  adapter: r2({
    bucket: 'agent-runs',
    accountId: process.env.R2_ACCOUNT_ID,
    accessKeyId: process.env.R2_ACCESS_KEY_ID,
    secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
  }),
});
r2({
  bucket: string;
  accountId: string;
  accessKeyId: string;
  secretAccessKey: string;
  endpoint?: string;       // override for EU / FedRAMP jurisdictions
});

Notes

Compatibility

CapabilitySupport
SnapshotsSibling buckets via server-side CopyObject
ForksSibling buckets via server-side CopyObject
Byte-range reads
Multipart upload
Enforced upload limits
User metadata
Signed URLs