ImageServer

module
v0.0.0-...-7a2f58c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2019 License: Apache-2.0

README

Go Report Card GoDoc

ImageServer

In this server you can send image to api and server save this image and creating preview image:

Work schemes:

  1. link to image;
  2. multipart/form-data;
  3. 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.

How to run

Don't forget add your user for docker group sudo usermod -aG docker $USER. Server run on port 4080

  1. Install Docker-CE (ubuntu)
  2. Install Docker compose
  3. sudo docker-compose up

Endpoints

http://localhost:4080/form_data

This endpoint allowed to work in two modes at once: query and multipart/form-data

  1. 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

  2. multipart/form-data automatically determined if the argument is a valid format picture.

http://localhost:4080/json_image

This endpoint only for json base64 image, the body of request, reply have only one image:

  1. Data - format img base;
  2. Body - body of image(in the example it is trimmed).
{
	"Data": "data:image/jpeg",
	"Body": "/9j/4AAQSkZJRgABAQEAYABgAAD/"
}

Answer for all endpoints

{
    "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

Api setup file in Json RFC7159 format, all arguments is necessary:

{
  "name": "Image Server",
  "version": "1.0.0",
  "host" : "localhost",
  "port" : "8080"
}

Directories

Path Synopsis
cmd
imageServer
api run file
api run file
pkg
v1
v1/headers
Package headers various structs for API
Package headers various structs for API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL