JEDIAH AI
Cloudflare R2 Setup Guide
Self-Hosted Media Storage for Generated Clips
๐ Table of Contents
- Overview โ What & Why
- What You'll Need
- Create a Cloudflare Account
- Set Up an R2 Bucket
- Create an API Token
- Enable Public Access (Custom Domain)
- Gather Your Credentials
- Connect Storage to Jediah AI
- What Happens Next (Build Phase)
- Estimated Cost Summary
- Pre-Build Checklist
1. Overview โ What & Why
Currently, every video and image your studio generates is stored on the current managed media storage and served from a URL that contains the managed-media host. This guide walks you through setting up Cloudflare R2 โ your own media storage bucket โ so that after a clip is generated, it's automatically copied to your bucket and served from your domain instead.
2. What You'll Need
| Item | Details |
|---|---|
| Email address | To register a Cloudflare account |
| A custom domain (optional but recommended) | e.g., jediahai.com or a subdomain like media.jediahai.com โ this is what appears in the clip URLs |
| 5โ10 minutes | The setup is quick |
| A credit card (for verification) | Required by Cloudflare even on the free tier; you won't be charged for low usage |
3. Create a Cloudflare Account
4. Set Up an R2 Bucket
5. Create an API Token
This token allows the app to upload files to your bucket programmatically.
6. Enable Public Access (Custom Domain)
So clips can be viewed in the browser without a signed URL, you'll connect a domain to your bucket.
- Under Custom Domains, click Connect Domain
- Enter a subdomain like media.jediahai.com
- If your domain is already on Cloudflare, it auto-configures. If not, you'll need to add your domain to Cloudflare first (DNS setup โ Cloudflare walks you through it).
7. Gather Your Credentials
You should now have these four pieces of information. Write them all in one place:
| Credential | Example |
|---|---|
| Bucket Name | jediah-ai-media |
| Account ID | Found on the right side of the Cloudflare dashboard home (a long alphanumeric string) |
| API Token | The token you copied in Step 5 |
| Public Base URL | https://media.jediahai.com or https://pub-xxxxx.r2.dev |
8. Connect Storage to Jediah AI
Once you have all four credentials, tell me (in this chat):
Then provide:
1. Bucket Name
2. Account ID
3. API Token
4. Public Base URL
I'll register them as secure secrets in the app (they're stored encrypted โ never visible in code or logs) and build the self-hosting pipeline.
9. What Happens Next (Build Phase)
Once you share your credentials, here's what I'll build:
- Backend function โ downloads each generated clip from managed storage and uploads it to your R2 bucket
- Updated generation flow โ after a clip is generated, it's automatically transferred and the stored URL is swapped to your branded one
- Fallback handling โ if a transfer fails, the clip still works (falls back to the original URL so nothing breaks)
- Testing โ I'll run a test generation to confirm the URL shows your domain
Timeline: Built and tested in the same session once credentials are provided.
10. Estimated Cost Summary
| Usage Level | Monthly Cost (R2) |
|---|---|
| Light (under 100 clips) | ~$0 (free tier covers it) |
| Medium (100โ1,000 clips) | $1โ5 |
| Heavy (1,000+ clips, lots of views) | $5โ20+ (still far cheaper than S3 due to $0 egress) |
11. Pre-Build Checklist
Before telling me you're ready, confirm you have all of these:
- Cloudflare account created and email verified
- R2 bucket created (bucket name noted)
- Payment method added to Cloudflare (for R2 activation)
- API token created and saved securely
- Account ID noted (from dashboard home)
- Public access enabled (R2.dev or custom domain)
- Public base URL noted
