Example of how to zip and unzip in Cloudflare Workers and uploading it to Cloudfalre's R2.
- Install all dependencies
npm i
- Get your cloudflare AccountId
npx wrangler whoami
Update the account ID in your wrangler.toml
in the ACCOUNT_ID
section.
- 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
- Run the worker
npx wrangler dev --local
Test that it works:
curl localhost:8787
{
"config": "hello world"
}