Skip to content

Instantly share code, notes, and snippets.

View Cherry's full-sized avatar

James Ross Cherry

View GitHub Profile
@Cherry
Cherry / worker.js
Created April 10, 2021 15:52 — forked from AggressivelyMeows/worker.js
A worker to upload and read files from a private B2 bucket.
// A simple guide on how to use this Worker.
// To upload to the private bucket, you can send a POST request to the URL you want the file to end up at.
// For example: worker-url.com/images/user-1/subfolder/hi.png
// Once done, you can test your file by going to:
// worker-url.com/images/user-1/subfolder/h1.png
// Super simple API to use, much better than dealing with B2 directly, in my opinion.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))