88
99```
1010# go image server
11- go 实现的图片服务, 提供基本的上传 , 存储, 缩放 , 下载等功能
11+ go 实现的图片服务, 提供上传 , 存储, 自动裁剪 , 下载等功能
1212
1313[ ![ stable] ( https://img.shields.io/badge/stable-stable-green.svg )] ( https://github.com/phachon/gis/ )
1414[ ![ license] ( https://img.shields.io/github/license/phachon/gis.svg?style=plastic )] ( )
@@ -18,24 +18,13 @@ go 实现的图片服务, 提供基本的上传, 存储, 缩放, 下载等功能
1818## 功能
1919- http 上传
2020- 图片存储
21- - 按比例自动缩放生成图片
21+ - 按比例裁剪图片
2222- 图片下载浏览
2323
2424## 安装
2525
26- 1 . 普通安装
27- 下载地址:https://github.com/phachon/gis/releases
28- 找到对应的版本下载
26+ 下载最新版本的二进制程序,下载地址:https://github.com/phachon/gis/releases
2927
30- 2 . 手动安装
31- http下载地址:https://github.com/phachon/gis.git
32- ssh 下载地址:
[email protected] : phachon /gis.git
33-
34- ```
35- cd gis
36- go get ./...
37- go build ./
38- ```
3928## 使用
4029- windows
4130
@@ -55,6 +44,7 @@ gis.exe --conf config.toml
5544
5645## 配置
5746
47+ #### config.toml
5848```
5949[listen]
6050# 监听上传 server
@@ -69,31 +59,33 @@ max_size = 2048 // 图片的最大上传大小 KB
6959root_dir = "upload" // 图片上传根目录
7060filename_len = 16 // 图片保存文件名字符串长度
7161dirname_len = 4 // 目录树的目录名长度
72- thumbnails = ["200_200", "300_300", "200_400"] // 要生成的缩略图尺寸 width_height
62+ thumbnails = ["200_200", "300_300", "200_400"] // 要生成的缩略图裁剪尺寸 width_height
7363
7464[download]
7565# 下载的地址 协议://域名:端口
7666uri = "http://test.com:8088"
7767
78- [appname] // appname 用于授权,可多个
68+ [appname] // appname 用于授权,可多个,app_key 需要和 客户端上传的 token 保持一致
7969 [appname.test]
8070 app_key = "ad%4a*a&ada@#ada"
8171 [appname.test1]
8272 app_key = "sd(4a*yu&dai#9d3"
8373```
8474
85- ## api 说明
75+ ## 接口说明
76+
77+ ### 上传图片接口
78+
79+ - 请求地址:/image/upload?
80+ - 请求方式:POST
81+ - 请求 Header: Appname, Token (用来验证上传合法性)
82+ - 返回格式:json
8683
87- - 上传接口
88- 地址:/image/upload?<br >
89- 请求方式:POST<br >
90- 请求 header :Appname, Token (用来验证上传合法性)<br >
91- 返回:json<br >
9284```
9385{
94- "code":"1", // 1:success, 0:error
95- "message":"", // error message
96- "data":{
86+ "code": "1", // 1:success, 0:error
87+ "message": "", // error message
88+ "data": {
9789 "image": "http://test.com:8088/image/LYEDBYKAFGGRJUFL.png"
9890 "image_200_200": "http://test.com:8088/image/LYEDBYKAFGGRJUFL_200_200.png"
9991 "image_200_400": "http://test.com:8088/image/LYEDBYKAFGGRJUFL_200_400.png"
@@ -102,24 +94,20 @@ uri = "http://test.com:8088"
10294}
10395```
10496
105- - 访问接口
106- 地址:/image/: imageName <br >
107- 请求方式:GET<br >
108- 返回:图片
109-
110- - Token 生成规则
97+ ### Token 生成规则
11198```
11299token = md5(appname+appKey)
113100```
114101
115- ## 客户端调用示例
116- - php <br >
117- https://github.com/phachon/gis/tree/master/_example/php/php.go
118- - go <br >
119- https://github.com/phachon/gis/tree/master/_example/go/upload.go
120- - html <br >
121- https://github.com/phachon/gis/tree/master/_example/html/index.html
102+ ### 下载图片接口
103+ - 接口地址:/image/: imageName
104+ - 请求方式:GET
105+ - 返回:图片
122106
107+ ## 客户端调用示例
108+ - [ php] ( https://github.com/phachon/gis/tree/master/_example/php/php.go )
109+ - [ go] ( https://github.com/phachon/gis/tree/master/_example/go/upload.go )
110+ - [ html] ( https://github.com/phachon/gis/tree/master/_example/html/index.html )
123111
124112## 反馈
125113
0 commit comments