Public buckets are now available! https://developers.cloudflare.com/r2/data-access/public-buckets/
A Cloudflare Worker to make your R2 bucket public!
- Cloudflare Account
wrangler >= 2.0.2
Note: Ensure you are using at the minimum specified version of wrangler.
-
Fork this repo
-
Install dependencies (including Wrangler 2)
npm install
- Create a bucket to be made public
wrangler r2 bucket create public
- Update the
wrangler.toml
to bind the R2 bucket
[[r2_buckets]]
binding = 'PUBLIC' # <~ valid JavaScript variable name
bucket_name = 'public'
- Deploy the worker!
wrangler publish
- 🎉 You've got a public bucket
Give it a try: https://r2-public-worker.cdmacken.workers.dev/duck.png
URL's even support spaces! https://r2-public-worker.cdmacken.workers.dev/space%20duck.webp