Logo
← Back to blog

How to connect a Cloudflare R2 bucket to file.rocks

Cover image

Connecting R2 to file.rocks is the same idea as S3, with less AWS console pain. You make a bucket, mint a token, and paste five fields.

If you already have a bucket and just want it on a custom domain, that's the other post. This one is how you hook R2 into file.rocks so you can browse and upload without living in the Cloudflare dashboard.

1. Create your R2 bucket

Open the Cloudflare dashboard and go to R2.

Click Create bucket. Give it a name you'll recognize later. You can leave the rest on the defaults.

Copy the bucket name. You'll paste it into file.rocks in a minute.

R2 bucket list in the Cloudflare dashboard

2. Make an R2 API token

R2 doesn't use IAM the way AWS does. You make an R2 API token.

In R2, open API Tokens (or Manage R2 API Tokens). Create a token with:

  • Permission: Object Read & Write
  • Scope: this bucket only, not all buckets

Cloudflare will show an Access Key ID and a Secret Access Key. The secret shows once. Copy both somewhere local. If you lose the secret you have to make a new token.

Create R2 API token form

3. Grab the endpoint and region

Your S3-compatible endpoint looks like this:

https://<ACCOUNT_ID>.r2.cloudflarestorage.com

Account ID is in the Cloudflare dashboard (R2 overview). Region for R2 in file.rocks is auto.

R2 account details with S3 API endpoint

4. Add the bucket in file.rocks

Go to file.rocks, sign in, and click Add a Bucket.

Paste:

  • Bucket name
  • Access key
  • Secret key
  • Endpoint
  • Region: auto

Save. You should see the bucket in the list.

file.rocks Add a Bucket form

If you've connected S3 before, this form is the same one. The Amazon S3 guide walks that path. R2 just swaps the endpoint and skips the IAM click-path.

5. Upload a file

Open Files and drop something in. If it lands, you're done. file.rocks is the UI now. Cloudflare still holds the objects.

file.rocks Files view

Want that bucket on a public domain later? Use How to add a custom public domain to a Cloudflare R2 bucket. Don't redo the token work.

How to connect a Cloudflare R2 bucket to file.rocks | file.rocks Blog