Store images on ImageStorage server using HTTP requests.
Figure 1 - Image Storage architectureFirst of all install alembic
on your local or virtual environment.
Set properly all parameters on settings.toml
and start containers.
docker-compose up
Invoke alembic migration
tool to development or production environment.
make run_migration_development
Invoke alembic migration
tool to test environment.
make run_migration_test
Run tests on api container.
docker exec -it <api-container> bash -c "python -m pytest --cov=src/image tests/"
POST /v1/images
# Post
data=$(base64 "image.jpg")
echo '{"data": "'$data'"}' > payload.json
curl -s -X POST http://localhost:5000/v1/images/ -d @payload.json -H 'Content-Type: application/json'
// Return
{
"id": <image_id>,
"path": <image_path>
}
GET /v1/images/<image_id>
# Get
curl http://localhost:5000/v1/images/<image_id>
// Return
{
"id": <image_id>,
"path": <image_path>
}
GET /v1/images?offset=10&limit=10
# Get
curl http://localhost:5000/v1/images
// Return
{
"kind": "Collection",
"next": "<host_url>/images?offset=10&limit=5",
"previous": "<host_url>/images?offset=5&limit=5",
"data": [
{
"id": <image_id>,
"path": <image_path>
},
{
"id": <image_id>,
"path": <image_path>
}
]
}
DELETE /v1/images/<image_id>
# DELETE
curl -s -X DELETE http://localhost:5000/v1/images/<image_id>
// Return
{
"image_id": '<image_id>'
}
MIT