Demo of Using Cloudflare R2 with Workers
This project demonstrates using Cloudflare Workers to control access to a
Cloudflare R2 bucket. Links to all sample files are after the videos.
Video Overview
-
Convert the official
"Using R2 in a Worker"
Cloudflare code sample from TypeScript to JavaScript
- Configure a Cloudflare R2 Bucket
- Create a Cloudflare Worker
- Bind the Worker to the R2 Bucket
- Demonstrate using the Worker to add files to the R2 Bucket
- Discuss the security concerns with the official demo code
-
Anyone can see a list of all files in the bucket (a.k.a. "Directory
Listing")
- Anyone can access all files in the bucket
- Anyone can add and delete files from the bucket
- Disable "Directory Listing"
- Add an authorization requirement to access the bucket
- Add an HTML page to the root of the bucket
All Sample Files