s3-cloudflare-r2
Use when working with AWS S3 or Cloudflare R2 for object storage — file uploads, presigned URLs, bucket policies, or CDN integration. Also use when choosing between S3 and R2 or implementing direct-to-storage uploads.
| Model | Source |
|---|---|
| sonnet | pack: storage |
Full Reference
┏━ 🔧 s3-cloudflare-r2 ━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when working with AWS S3 or Cloudflare R2 … ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
S3 / Cloudflare R2
Section titled “S3 / Cloudflare R2”Both use the same SDK: @aws-sdk/client-s3. R2 is S3-compatible — swap the endpoint, keep the code. Node.js 20.x+ required (Node 18 dropped from SDK in January 2026).
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Install | npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner |
| SDK | @aws-sdk/client-s3 v3.x (modular) |
| S3 endpoint | AWS regional (auto-detected from AWS_REGION) |
| R2 endpoint | https://<ACCOUNT_ID>.r2.cloudflarestorage.com |
| R2 region value | "auto" (required — not a real AWS region) |
| S3 key env vars | AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY |
| R2 key env vars | R2_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY |
| Node.js | 20.x+ required |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Configure the S3 or R2 client and set up credentials | reference/setup.md |
| Upload, download, or check file existence | reference/upload.md |
| Generate presigned PUT/GET URLs for direct browser uploads | reference/presigned-urls.md |
| List objects, delete files, or set bucket policies | reference/list-delete.md |
| Upload large files (100MB+) with multipart and parallel parts | reference/multipart.md |
| Configure CORS, set up CloudFront or R2 custom domain, or compare S3 vs R2 | reference/cors.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.