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

  1. Log in to the Cloudflare dashboard → left side R2
  2. Click Create bucket → name it (e.g. cfos-files) → create
  3. Note the bucket name

2. Create an R2 API token

  1. Top-right of the R2 page → "Manage R2 API Tokens"
  2. Create API token → permission Object Read & Write
  3. Get:
    • Access Key ID
    • Secret Access Key (shown only once, copy immediately)

3. Find your Account ID

  1. You can see Account ID in the top-right or right sidebar of the Cloudflare dashboard
  2. 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

SymptomCause
Upload says "R2 not configured"One of the 4 R2 variables is missing
Upload failsR2 token lacks the right permission (needs Read & Write)
Link expiredExpiry reached — upload again