27 Star 124 Fork 25

phachon / gis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT
             _
   ____ _   (_)  _____
  / __  /  / /  / ___/
 / /_/ /  / /  (__  )
 \__, /  /_/  /____/
/____/

go image server

go 实现的图片服务, 提供上传, 存储, 自动裁剪, 下载等功能

stable license download_count release

功能

  • http 上传
  • 图片存储
  • 按比例裁剪图片
  • 图片下载浏览

安装

下载最新版本的二进制程序,下载地址:https://github.com/phachon/gis/releases

使用

  • windows
gis.exe
# 指定配置文件启动
gis.exe --conf config.toml
  • linux
./gis
# 指定配置文件启动
./gis --conf 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 用于授权,可多个,app_key 需要和 客户端上传的 token 保持一致
    [appname.test]
    app_key = "ad%4a*a&ada@#ada"
    [appname.test1]
    app_key = "sd(4a*yu&dai#9d3"

接口说明

上传图片接口

  • 请求地址:/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
}

Token 生成规则

token = md5(appname+appKey)

下载图片接口

  • 接口地址:/image/:imageName
  • 请求方式:GET
  • 返回:图片

客户端调用示例

反馈

欢迎提交意见和代码,联系方式 phachon@163.com

License

MIT

Thanks

Create By phachon@163.com

Copyright (c) 2017 phachon@163.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

gis (go image server) go 实现的图片服务,实现基本的上传,下载,存储,按比例裁剪等功能 展开 收起
Go
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/phachon/gis.git
git@gitee.com:phachon/gis.git
phachon
gis
gis
master

搜索帮助