In this server you can send image to api and server save this image and creating preview image:
Work schemes:
- link to image;
- multipart/form-data;
- image in base64.
Allows formats: jpg, jpeg, png. All images save in images
folder and if you want you can open it.
Project use Go modules to download dependencies.
You can see dependencies in go.mod
Test requests you can find in folder: cmd/test_client
run it, when api is running, don't forget change ports.
Don't forget add your user for docker group sudo usermod -aG docker $USER
. Server run on port 4080
- Install Docker-CE (ubuntu)
- Install Docker compose
sudo docker-compose up
This endpoint allowed to work in two modes at once: query
and multipart/form-data
-
This endpoint can work with query argument
image
example:http://localhost:4080/form_data?image=https://img.zoneofgames.ru/news/2019/04/22/190216-banner_conk_20190422_PaganOnline.jpg
-
multipart/form-data automatically determined if the argument is a valid format picture.
This endpoint only for json base64 image, the body of request, reply have only one image:
- Data - format img base;
- Body - body of image(in the example it is trimmed).
{
"Data": "data:image/jpeg",
"Body": "/9j/4AAQSkZJRgABAQEAYABgAAD/"
}
{
"Status": 200,
"Description": "",
"Images": [
{
"Source": "images/74b51062-6b62-481d-acf1-b44d4e08ad91.jpeg",
"Preview": "images/74b51062-6b62-481d-acf1-b44d4e08ad91_preview.jpeg"
},
{
"Source": "images/a2d3ba2e-5a9c-4840-ade8-8d5c9c81d4c2.jpg",
"Preview": "images/a2d3ba2e-5a9c-4840-ade8-8d5c9c81d4c2_preview.jpg"
}
]
}
Api setup file in Json RFC7159 format, all arguments is necessary:
{
"name": "Image Server",
"version": "1.0.0",
"host" : "localhost",
"port" : "8080"
}