Cloudflare R2 Configuration Guide
Service Overview
Cloudflare R2 is Cloudflare's object storage service, compatible with the S3 API. R2's biggest feature is zero egress fees - reading data from R2 requires no traffic fees.
Official Website: https://www.cloudflare.com/products/r2/
Official Documentation: https://developers.cloudflare.com/r2/
Pricing (as of 2024):
- Storage: $0.015/GB/month
- Class A operations (write): $4.50/million requests
- Class B operations (read): $0.36/million requests
- ✅ Egress traffic: Completely free
Configuration Parameters
Endpoint
R2 endpoint format:
https://<account-id>.r2.cloudflarestorage.comFinding Account ID:
- Log into Cloudflare Dashboard
- View right sidebar, Account ID is displayed below account name
- Or get from R2 page URL:
https://dash.cloudflare.com/<account-id>/r2
Example endpoint:
https://abc123def456789.r2.cloudflarestorage.comRegion
Recommended to use auto, R2 will automatically select the best location.
Optional region values:
auto- Automatic selection (recommended)wnam- Western North Americaenam- Eastern North Americaweur- Western Europeeeur- Eastern Europeapac- Asia Pacific
Obtaining Access Keys
Create R2 API Token
Enter R2 Management Page
- Log into Cloudflare Dashboard
- Click "R2" in left menu
- If first time, need to purchase R2 subscription (can choose free plan)
Manage API Tokens
- Click "Manage R2 API Tokens" in top right
- Or go directly to: Settings → R2 → API Tokens
Create Token
- Click "Create API Token" button
- Enter token name (e.g.,
s3-file-viewer-token)
Configure Permissions
Permission Types:
- Admin Read & Write: Full access to all buckets (not recommended)
- Object Read & Write: Read/write objects (recommended)
- Object Read only: Read-only access
Save Keys
- Access Key ID: 32 characters, e.g.,
a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6 - Secret Access Key: 64 characters
- ⚠️ Important: Secret Key is only shown once, must save immediately
- Access Key ID: 32 characters, e.g.,
Configuration Examples
Basic Configuration
Connection Name: Cloudflare R2
Endpoint: https://abc123def456789.r2.cloudflarestorage.com
Access Key: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Secret Key: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
Region: autoSpecified Region Configuration
Connection Name: R2 Asia Pacific
Endpoint: https://abc123def456789.r2.cloudflarestorage.com
Access Key: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Secret Key: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
Region: apac