chore: readme
This commit is contained in:
parent
9a2ab9ad22
commit
10d258590f
1 changed files with 59 additions and 0 deletions
59
README.md
Normal file
59
README.md
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# Kanzashi image CDN
|
||||
Named after Nintendo's original implementation, this is a rocket web server designed to hold and manage images at a large scale.
|
||||
|
||||
## Uploading
|
||||
Uploading images requires a `POST` request to `/upload` formatted as `multipart/form-data` with a form field named `file`.
|
||||
### Required Headers
|
||||
|
||||
| Header Name | Value / Format | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| `X-Timestamp` | `<current_unix_timestamp>` | Current UTC time in seconds (e.g., `1711200000`). |
|
||||
| `X-Signature` | `<hex_encoded_signature>` | Ed25519 hex signature of `POST:/upload:<X-Timestamp>`. |
|
||||
| `Content-Type` | `multipart/form-data; boundary=...` | Required for multipart request parsing |
|
||||
|
||||
> [!NOTE]
|
||||
> The uploaded file's extension must match one of the extensions defined in `ALLOWED_EXTENSIONS` (e.g., `.png`, `.jpg`).
|
||||
|
||||
## Running
|
||||
### Requirements
|
||||
- Cargo with Rust 2024
|
||||
- SQLite compatible OS
|
||||
- S3 Server (minIO recommended)
|
||||
- A brain
|
||||
|
||||
### .env configuration
|
||||
A .env.example is provided for your convenience.
|
||||
|
||||
| Name | Example Value | Description |
|
||||
|-------|-----|------------|
|
||||
| MINIO_ENDPOINT | http://127.0.0.1:9000 | S3 Server Location
|
||||
| MINIO_ACCESS_KEY | minioadmin | S3 Server Access Key |
|
||||
| MINIO_SECRET_KEY | minioadminpassword | S3 Server Secret Key |
|
||||
| MINIO_REGION | us-east-1 | S3 Server location. Traditionally not needed, varies depending on setup.
|
||||
| ALLOWED_BUCKET | kanzashi | Bucket the server is restricted to store files in |
|
||||
| DB_PASSPHRASE | redacted | SQLite DB Pass |
|
||||
| ALLOWED_EXTENSIONS | jpg,jpeg,png,gif,webp | List of allowed file extensions that can be uploaded. Anything else is rejected. |
|
||||
|
||||
### Build
|
||||
```bash
|
||||
cargo build
|
||||
```
|
||||
|
||||
### Run
|
||||
```bash
|
||||
cargo run
|
||||
```
|
||||
|
||||
### Adding/revoking tokens
|
||||
To upload to the CDN, you need a token. The panel can be accessed at /admin. Once there, check the console. You may have to scroll up to before rocket, but you will see:
|
||||
|
||||
```
|
||||
====================
|
||||
key: xxx
|
||||
Panel located at /admin?key=xxx
|
||||
====================
|
||||
```
|
||||
|
||||
This key is regenerated upon every server restart. Keep it safe! It used for generating and revoking tokens. It should not be shared willy nilly.
|
||||
|
||||
Once into the panel, type in your application name and click `Generate Key Pair`. Now you have generated a private key. The public key will be available in the panel, however you must save the private key. If your application requires uploading to the CDN, this is what you will use.
|
||||
Loading…
Reference in a new issue