blazingly-fast super-concurrent webscale file server
Go to file
Julian 3d63b02e8d
add nix documentation
2023-04-28 15:06:39 -04:00
migrations maintenance 2023-04-28 13:19:02 -04:00
src add / route 2023-04-28 15:03:11 -04:00
.gitignore maintenance 2023-04-28 13:19:02 -04:00
Cargo.lock nix 2023-04-28 18:53:30 +00:00
Cargo.toml nix 2023-04-28 18:53:30 +00:00
LICENSE init 2023-03-04 19:29:56 -05:00
README.md add nix documentation 2023-04-28 15:06:39 -04:00
flake.lock nix 2023-04-28 18:53:30 +00:00
flake.nix nix 2023-04-28 18:53:30 +00:00
sqlx-data.json nix 2023-04-28 18:53:30 +00:00
upload.sh nix 2023-04-28 18:53:30 +00:00

README.md

u

blazingly-fast super-concurrent webscale file server

setup

requirements:

  • git
  • rust toolchain
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
export U_API_KEY="..."
export U_HOST="https://..."
export U_REVOCATION_KEY_PATH="$HOME/.u_revocation_keys"

./upload.sh /path/to/file

setup (nix)

u has a nix flake you can use - just add u.url = "git+https://git.n2.pm/NotNite/u.git";. both the server (u) and client (u-upload) are available as packages.

you can also use the NixOS module (u.nixosModule) and enable services.u.

using u

examples are with curl - you can (obviously) use any HTTP client.

creating a new API key

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

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

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.