File Sharing (Cloudflare R2)
Upload files to Cloudflare R2 and generate expiring download links. Downloads stream from R2, not Vercel.
1. Create an R2 bucket
- Log in to the Cloudflare dashboard → left side R2
- Click Create bucket → name it (e.g.
cfos-files) → create - Note the bucket name
2. Create an R2 API token
- Top-right of the R2 page → "Manage R2 API Tokens"
- Create API token → permission Object Read & Write
- Get:
- Access Key ID
- Secret Access Key (shown only once, copy immediately)
3. Find your Account ID
- You can see Account ID in the top-right or right sidebar of the Cloudflare dashboard
- Copy it
4. Configure in Vercel
Add environment variables:
R2_ACCOUNT_ID=your-account-id
R2_ACCESS_KEY_ID=your-access-key-id
R2_SECRET_ACCESS_KEY=your-secret-access-key
R2_BUCKET=your-bucket-name
Redeploy to apply. The File Sharing item in the sidebar will work.
Features
- Upload files with an optional expiry (1/7/14/30 days)
- Copy / open download links
- Auto-delete on expiry (lazy delete on access + daily cron cleanup)
- Downloads use R2 presigned direct links — no Vercel bandwidth
FAQ
| Symptom | Cause |
|---|---|
| Upload says "R2 not configured" | One of the 4 R2 variables is missing |
| Upload fails | R2 token lacks the right permission (needs Read & Write) |
| Link expired | Expiry reached — upload again |
