provide a minimal HTTP based API to allow the users to do the following:
- Allow a PDF or image file to be uploaded.
- User must be able to attach some key & value style tags to the document upload
- Allow a PDF or image file to be deleted
- The file will be deleted from our system
- Allow a PDF or image file to be retrieved, along with any metadata
- API users should be able to fetch by a reference they have supplied, in addition to any reference we may have returned
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
To deploy this project in docker please run the following commands from project root
./gradlew build
docker build -t image_api .
docker run -p 8080:8080 image_api
As this is just a sample project the default username and password is user:password
localhost:8080/api/v1/images
Param | value | Type |
---|---|---|
file | @"path/to/file" | text |
metadata | "{'key':'value'}" | text |
extId | "someExternalId" | text |
{
"id": "a364e742-832c-4e71-9826-7a0d4babfe32"
}
curl -F file=@"/path/to/jpg-test.jpeg" -F metadata="{'key1':'value1', 'key2':'value2'}" -F externalId=someExternalId123 localhost:8080/api/v1/images --user 'user:password'
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
localhost:8080/api/v1/images?id=<String (UUID)>&extId=<String someExternalId>
Param | value |
---|---|
id | <String (UUID)> |
extId |
{
"id": "a364e742-832c-4e71-9826-7a0d4babfe32",
"externalId": "someExternalId",
"metaData": {
"key1": "value1",
"key2": "value2"
},
"imageType": "image/jpeg",
"imageBlob": "<urlEncodedByteArray>"
}
curl -get 'localhost:8080/api/v1/images?id=uuid' --user 'user:password'
curl -get 'localhost:8080/api/v1/images?externalId=someExternalId' --user 'user:password'
⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃
localhost:8080/api/v1/images?id=<String (UUID)>&extId=<String someExternalId>
Param | value |
---|---|
id | <String (UUID)> |
extId |
{
"deleted": true
}
curl -X DELETE 'localhost:8080/api/v1/images?id=uuid' --user 'user:password'
curl -X DELETE 'localhost:8080/api/v1/images?externalId=someExternalId' --user 'user:password'