Simple HTTP API for reading, listing, uploading and deleting files from a server.
First, create a file .apikeys
with whitelisted random-generated API keys on each line.
Create a docker-compose.yml
:
services:
file-storage-api:
image: ghcr.io/testausserveri/file-storage-api
volumes:
- ./.apikeys:/app/.apikeys
- ./media:/app/uploads
ports:
- 8080:8080
Run:
$ docker compose up
Method | Path | Description | Sample |
GET | / | Return list of files |
200 OK
{
"files": [
"7he9s-logo.jpg",
"hsmpy-logo.jpg",
"zb8ae-logo.jpg"
]
} |
POST | / | Upload a file in file form-data key |
200 OK
{
"filename": "7he9s-logo.jpg"
} |
GET | /filename | Get file |
200 OK
The requested file |
DELETE | /filename | Delete file |
200 OK
{
"filename": "7he9s-logo.jpg"
} |
All endpoints require an authorization. It is passed to the authorization header with an value ApiKey your-api-key
.
Authorization: ApiKey your-api-key
Add your own API keys to .apikeys
file, each on their own line.
Errors are responded with a non-200 status code and a JSON-object such as:
{
"error": "reason"
}