le sac is a small file-store server in Go.
- HTTP adapter (
PUT,GET,DELETE) with a transport-agnostic core service. - Pluggable storage architecture (filesystem implemented now).
- SQLite metadata store.
- Optional file lifetime (TTL) in seconds.
- TOML configuration.
- Configurable HTTP auth (
none,write,all) with bearer/basic/API key schemes. - Service-friendly runtime (foreground process + graceful shutdown on signals).
Stores the raw request body as a file.
- Query parameter:
lifetime(optional, in seconds). lifetime=0is invalid and returns400.mimetypeis derived fromContent-Type; when missing/generic (for examplecurl --data-binarydefault), the server sniffs bytes to detect type.- Success response:
{
"id": "<unique-id>",
"url": "http://<host>/v1/files/<unique-id>",
"mimetype": "text/plain",
"extension": "txt"
}Status: 201 Created
Stores multiple files in one request.
- Content type:
multipart/form-data - Repeated file field name:
files - Query parameter:
lifetime(optional, in seconds, applied to all files)
Response body:
{
"results": [
{
"index": 0,
"id": "<unique-id>",
"url": "http://<host>/v1/files/<unique-id>",
"mimetype": "image/png",
"extension": "png"
},
{ "index": 1, "error": "failed to store file" }
]
}201 Created: all files stored207 Multi-Status: partial success500 Internal Server Error: all files failed400 Bad Request: invalid lifetime or invalid/missing multipart file parts
Retrieves raw file bytes.
- Status:
200 OKon success. - Status:
404 Not Foundwhen file is missing or expired. - Response
Content-Typeis the stored filemimetypewhen available, otherwiseapplication/octet-stream.
Deletes a file.
- Idempotent: missing IDs still return success.
- Status:
204 No Content
go run ./cmd/lesac -config ./config.tomlSee config.toml. Key defaults:
uploads.max_upload_size = 67108864(64 MiB)storage.driver = "filesystem"server.auth.mode = "none"
Configure auth in [server.auth]:
mode = "none": no auth (default)mode = "write": auth required forPUT/POST/DELETEmode = "all": auth required for all endpoints, includingGET
Supported schemes (enabled when configured):
- Bearer:
bearer_tokens = ["token-1"] - Basic:
[server.auth.basic_users]table (username = "password") - API key:
api_keys = ["key-1"]+api_key_header = "X-API-Key"
Upload:
curl -X PUT --data-binary @myfile.bin "http://localhost:8080/v1/files?lifetime=300"Batch upload:
curl -X POST "http://localhost:8080/v1/files/batch?lifetime=300" \
-F "files=@a.bin" \
-F "files=@b.bin"Download:
curl -o myfile.bin "http://localhost:8080/v1/files/<id>"Delete:
curl -X DELETE "http://localhost:8080/v1/files/<id>"