This is a sample Spring Boot application that uses GraalVM to build a native image. The microservice handles images and can receive and upload them. If images have been uploaded they can also be resized to a smaller size to fit a thumbnail.
Runs on port 8001.
Start a mySQL docker container;
docker run --name imageDB -e MYSQL_ROOT_PASSWORD=secret-pw -e 'MYSQL_ROOT_HOST=%' -e MYSQL_DATABASE=images -e MYSQL_USER=developer -e MYSQL_PASSWORD=password -v $HOME/var/lib/mysql:/var/lib/mysql -p 3306:3306 mysql:latest
download the image and run the image: docker pull ghcr.io/chatgut/imageservice:main
The following endpoints are available:
Request Parameters:
image- The image file to upload.
Returns a string with a url to the image;
Example:
-
input:
image - examplePic.png -
output:
http://localhost:8001/images/1 -
url is auto generated, if running with a gateway, output would looks something like
http://foo:8080/images/1
Request Parameters:
url - http://localhost:8001/images/1
returns the image. Currently content-Type is image/png
Example:
-
input:
http://localhost:8001/images/1 -
output:
examplePic.png
This endpoint takes an existing image already uploaded and returns it as a resized image. Main use is for creating thumbnails.
Request Parameters:
url - http://localhost:8001/images/thumbnail/1- url paramaters is
heightandwidthany integer value is accepted.
Example:
-
input:
http://localhost:8001/images/thumbnail/8?height=200&width=200 -
output:
examplePic.png(resized to 200x200 pixels.
200 OKif image is uploaded
200 OKif there is a image to return404 NOT FOUNDif there is no matching image
200 OKif there is an existing image already uploaded404 NOT FOUNDif there is no matching image