update readme for r2

This commit is contained in:
EGOIST 2022-05-15 00:54:48 +08:00
parent 31362b5b86
commit 50bc2d64e2
1 changed files with 3 additions and 4 deletions

View File

@ -3,13 +3,12 @@ A cloudflare worker based REST API for your R2 bucket.
Usage:
- Change the `bucket_name` and `preview_bucket_name` in `wrangler.toml` if you want.
- Set `API_TOKEN` in the worker secrets using Wrangler CLI.
- Set `ENCRYPT_SECRET` (>= 32 chars) in the worker secrets using Wrangler CLI.
Endpoints:
- GET `/:key`: Public access
- POST `/`: Require `authorization: Bearer TOKEN` header, where `TOKEN` should match `API_TOKEN` from your worker secrets. The request content type should be `multipart/form-data` with following fields:
- `prefix`: optional prefix for the key, see blow
- POST `/`: Require `authorization: Bearer TOKEN` header, where `TOKEN` is an encrypted JWT using `@proselog/jwt` and `ENCRYPT_SECRET`. The request content type should be `multipart/form-data` with following fields:
- `file`: `File` file to upload
The object key is generated from `prefix` + `uuid()` + `file.extension`
The object key is generated from `$userId/` + `uuid()` + `file.extension`