This is an example worker for the R2 Uploader, you can use the code in the ./dist folder directly, or build the code yourself.
- Bun installed
-
Clone this repository
git clone https://github.com/monochrome-music/r2-uploader.git
-
Install the dependencies
bun install
-
Edit
wrangler.toml, changer2_buckets -> bucket_nameto your own bucket name -
Deploy the code
bun run deploy
-
Push your API key
npx wrangler secret put AUTH_KEY_SECRET
This command will prompt you input the value, press
Enterto confirm.
And that's it, your worker is now ready to be used in R2 Uploader.
- Upload only: No viewing, listing, or deleting files
- Max file size: 10MB per upload
- Unique filenames: Random 8-char prefix on all uploads
- API key required: Set
AUTH_KEY_SECRETsecret
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Health check |
| PUT | /:key |
Upload file (max 10MB) |