38 lines
814 B
Markdown
Raw Normal View History

2022-05-29 10:02:40 +09:00
# r2-image-server
2022-05-22 22:46:08 +09:00
2022-05-29 22:06:06 +09:00
* An example server of R2.
* This server can store / load / delete images in R2.
2022-05-22 22:46:08 +09:00
2022-05-29 22:06:06 +09:00
## Usage
2022-05-22 22:46:08 +09:00
2022-05-29 22:06:06 +09:00
### Endpoints
2022-08-03 00:30:17 +09:00
* **GET `/{key}`**
2022-05-29 22:06:06 +09:00
- Get an image object at the `key` and returns it.
2022-08-03 00:30:17 +09:00
* **POST `/{key}`**
2022-05-29 22:06:06 +09:00
- Create an image object at the `key` and uploads image.
- Request body must be binary and request header must have `Content-Type`.
2022-08-03 00:30:17 +09:00
* **DELETE `/{key}`**
2022-05-29 22:06:06 +09:00
- Delete an image object at the `key`.
2022-05-22 22:46:08 +09:00
## Development
2022-05-29 22:06:06 +09:00
* See the following documents for details on how to use R2.
- https://developers.cloudflare.com/r2/runtime-apis
- https://pkg.go.dev/github.com/syumai/workers
2022-05-22 22:46:08 +09:00
### Requirements
This project requires these tools to be installed globally.
* wrangler
* tinygo
### Commands
```
make dev # run dev server
make build # build Go Wasm binary
make deploy # deploy worker
2022-05-22 22:46:08 +09:00
```