This project is a simple API writen in Python with Fast-API to store and serve images, featuring a simple authentication.
- Ensure your docker is set up correctly
- Clone this repository:
git clone https://github.com/forest-cat/simple-image-storage.git - Navigate into it:
cd simple-image-storage - Configure a Token via the
SIS_ACCESS_TOKENenvironment variable in thedocker-compose.yml - Build the container with:
docker compose build - Run the application using:
docker compose up -d
- Ensure you have access to a working
uvinstallation - Clone this repository:
git clone https://github.com/forest-cat/simple-image-storage.git - Navigate into it:
cd simple-image-storage - Run
uv syncto ensure all packages are installed - Copy the
example_config.ymlfrom this repository and set a token, you can change all other values or remove them because they're the default values and don't change anything - Start the application using
uv run app/main.py
To use the application i recommend using curl or by using any request library in your favorite language
To upload an use the following curl command:
curl -F 'file=@<filepath>' -H "Authorization: Bearer <token>" <endpoint-root-url>/upload/<integer-id>The integer-id can be any given id you want the image to be accessible on later.
The endpoint-root-url is the endpoint for the api, it could look like this: https://example.com
To download an image use the following curl command:
curl -o output.webp <endpoint-root-url>/image/<integer-id>Note: The output file here has the .webp extension because all images uploaded to the api will be automatically converted to a webp file and only served as such to save bandwith.