76 lines
1.8 KiB
Markdown
76 lines
1.8 KiB
Markdown
# u
|
|
|
|
blazingly-fast super-concurrent webscale file server
|
|
|
|
## setup
|
|
|
|
requirements:
|
|
|
|
- git
|
|
- rust toolchain
|
|
|
|
```sh
|
|
git clone https://git.n2.pm/NotNite/u.git
|
|
cd u
|
|
|
|
cat <<EOF >> .env
|
|
DATABASE_URL="sqlite:/somewhere/u.db"
|
|
U_PORT="8075"
|
|
U_FILES_DIR="/somewhere/files"
|
|
EOF
|
|
|
|
cargo build --release
|
|
```
|
|
|
|
on first run, it'll print out the admin key - keep that safe. you need it to create more API keys.
|
|
|
|
while losing the database isn't the end of the world (only contains API keys and revocation keys for files), obviously keep your files directory safe.
|
|
|
|
## setup (client)
|
|
|
|
requirements:
|
|
|
|
- api key for an existing u server
|
|
- coreutils, `curl`, `jq`, `xclip`
|
|
|
|
```sh
|
|
export U_API_KEY="..."
|
|
export U_HOST="https://.../"
|
|
export U_REVOCATION_KEY_PATH="$HOME/.u_revocation_keys"
|
|
|
|
./upload.sh /path/to/file
|
|
```
|
|
|
|
## using u
|
|
|
|
examples are with curl - you can (obviously) use any HTTP client.
|
|
|
|
### creating a new API key
|
|
|
|
```sh
|
|
curl -X POST -H "Authorization: $U_API_KEY" "$U_HOST/api/new_key"
|
|
```
|
|
|
|
requires an admin key to execute. you can give this API key to someone else so they can use your instance.
|
|
|
|
you can't modify API keys (delete or make admin) through the API - you'll have to open your database in your favorite sqlite client and edit the row manually.
|
|
|
|
### uploading a file
|
|
|
|
```sh
|
|
curl -F file=@/path/to/file -H "Authorization: $U_API_KEY" "$U_HOST/api/upload"
|
|
```
|
|
|
|
the `upload.sh` in this repository is just a wrapper around this curl command.
|
|
|
|
### deleting a file
|
|
|
|
```sh
|
|
curl -X DELETE "$U_HOST/i/$file_id?revocation_key=$revocation_key"
|
|
```
|
|
|
|
`file_id` and `revocation_key` are the values returned by the upload endpoint. if using `upload.sh`, the revocation key is stored in `$U_REVOCATION_KEY_PATH`.
|
|
|
|
### accessing files
|
|
|
|
files can be accessed with the URL `$U_HOST/i/$file_id`. you can add a file extension to the path if you want the server to return a specific mime type.
|