Giter Site home page Giter Site logo

go-imageserver's Introduction

go-imageServer

go 实现的图片服务, 提供基本的上传,存储,缩放,下载等功能

功能

  • http 上传
  • 图片存储
  • 按比例自动缩放生成图片
  • 图片浏览

安装

  1. 普通安装
    下载地址:https://github.com/phachon/go-imageServer/releases
    找到对应的版本下载
  2. 手动安装
    http下载地址:https://github.com/phachon/go-imageServer.git
    ssh 下载地址:[email protected]:phachon/go-imageServer.git
cd go-imageServer
go get ./...
go build ./

访问

  • windows:
    go-imageServer.exe
  • linux:
    ./go-imageServer

配置文件

config.toml 文件读取顺序:

  • /etc/go-imageServer/config.toml
  • $HOME/.go-imageServer/config.toml
  • ./config.toml
[listen]
# 监听上传 server
upload="127.0.0.1:8087"
# 监听下载 server
download="127.0.0.1:8088"

[upload]
form_field="upload" // 表单提交字段
allow_type = [".jpg", ".jpeg", ".png"] // 允许上传的图片格式
max_size = 2048 // 图片的最大上传大小 KB
root_dir = "upload" // 图片上传根目录
filename_len = 16 // 图片保存文件名字符串长度
dirname_len = 4  // 目录树的目录名长度
thumbnails = ["200_200", "300_300", "200_400"] // 要生成的缩略图尺寸 width_height

[download]
# 下载的地址 协议://域名:端口
uri = "http://test.com:8088"

[appname] // appname 用于授权,可多个
    [appname.test]
    app_key = "ad%4a*a&ada@#ada"
    [appname.test1]
    app_key = "sd(4a*yu&dai#9d3"

api 说明

  • 上传接口 地址:/image/upload?
    请求方式:POST
    请求 header :Appname, Token (用来验证上传合法性)
    返回:json
{
  "code":"1",   // 1:success, 0:error
  "message":"", // error message
  "data":{
       "image": "http://test.com:8088/image/LYEDBYKAFGGRJUFL.png"
       "image_200_200": "http://test.com:8088/image/LYEDBYKAFGGRJUFL_200_200.png"
       "image_200_400": "http://test.com:8088/image/LYEDBYKAFGGRJUFL_200_400.png"
       "image_300_300": "http://test.com:8088/image/LYEDBYKAFGGRJUFL_300_300.png"
   }, // server image url
}
  • 访问接口 地址:/image/:imageName
    请求方式:GET
    返回:图片

  • Token 生成规则

token = md5(appname+appKey)

客户端调用示例

反馈

欢迎提交意见和代码,联系方式 [email protected]

License

MIT

Thanks

Create By [email protected]

go-imageserver's People

Contributors

phachon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.