This project provides a key-value persistent containerized microservice with mongo.
It allows to set, retrieve and delete various files. Files are removed after specified ttl if present. Files are stored in local filesystem but it is easy to move to a remote storage.
Requests are authenticated with grpc sso. App checks whether user is authenticated and then performs gRPC request so SSO server to check users permissions.
Running gRPC SSO application is required. App must be registered in SSO. JWT tokens are obtained via sso mentioned above.
- Configure .env files, located in ./mongo/.env and ./api/.env based on corresponding .env.example files
- run
docker compose up
Token must be present in Authorization header:
Authorization: Bearer {jwt-token-here}
POST /api/v1/storage/:key (accepts multipart/form-data and overwrites previously set key)
name type data type description file required file A file to be stored: photo, audio, video, etc ttl optional int Key will be removed and file will be deleted after after now + ttl. A default value of 0 will set ttl to infinity.
http code content-type response 200application/json; charset=utf-8{"message": "Set :key"}422application/json; charset=utf-8{"message": "Error description here"}
GET /api/v1/storage/:key
http code content-type response 200depend on file mime{"message": "Set :key"}404application/json; charset=utf-8{"message": ":key is not found"}
DELETE /api/v1/storage/:key
http code content-type response 200application/json; charset=utf-8{"message": "ok"}404application/json; charset=utf-8{"message": ":key is not found"}