kosborn / jszip-workers-r2

Use jszip with Cloudflare workers and R2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using JSZip with Cloudflare Workers and R2

Example of how to zip and unzip in Cloudflare Workers and uploading it to Cloudfalre's R2.

Run

  1. Install all dependencies
npm i
  1. Get your cloudflare AccountId
npx wrangler whoami

Update the account ID in your wrangler.toml in the ACCOUNT_ID section.

  1. Create an R2 bucket

You'll need to create one for production and another one for testing locally

npx wrangler r2 bucket create BUCKET_NAME
npx wrangler r2 bucket create PREVIEW_BUCKET_NAME

Replace the name of the buckets in your wrangler.toml

  1. Run the worker
npx wrangler dev --local

Test that it works:

curl localhost:8787
{
  "config": "hello world"
}

About

Use jszip with Cloudflare workers and R2


Languages

Language:TypeScript 100.0%