Skip to content

muhfajar/storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Storage

Sample code Cloudflare Worker to make your R2 bucket accessible from public.

Minimum Requirements

  1. Cloudflare Account
  2. wrangler >= 2.0.2

Note: Ensure you are using at the minimum specified version of wrangler.

Setup

  1. Install dependencies (including Wrangler 2)
npm install
  1. Create a bucket to be made public
wrangler r2 bucket create {{BUCKET_NAME}}
  1. Update the wrangler.toml to bind the R2 bucket
[[r2_buckets]]
binding = 'PUBLIC' # <= make sure this var is valid JavaScript variable name
bucket_name = 'public'
  1. Deploy the worker!
wrangler publish src/index.ts --name {{WORKER_NAME}}
  1. Done 🎉

Give it a try: https://cdn.muhfajar.id/assets/glitch/v1/img/glitch.jpg

Releases

No releases published

Packages

No packages published