经过查找 github.com, 发现上传图片的 API都是以python为主,但是在实际的使用过程当中,需要用golang,所以就特意写了一个golang版本的。
源代码地址 https://github.com/sndnvaps/sm_ms_api
Golang 版本的 https://sm.ms API接口
如何安装
go get github.com/sndnvaps/sm_ms_api
支持如下功能
函数原型
func Upload(filename string) (map[string]interface{}, error)
func Delete(delUrlLink string) string
func ListUploadHistory() (HistoryMsgBody, error)
返回值定义结构体
//所有错误返回
type ErrMsgBody struct {
Code string `json:"code"`
Msg string `json:"msg"`
}
//用于 Upload() func
type MsgBody struct {
Code string `json:"code"`
Data DataInfo `json:"data"`
}
//用于 ListUploadHistory() func
type HistoryMsgBody struct {
Code string `json:"code"`
Data []DataInfo `json:"data"`
}
type DataInfo struct {
Width int `json:"width"`
Height int `json:"height"`
FileName string `json:"filename"`
StoreName string `json:"storename"`
Size int `json:"size"`
Path string `json:"path"`
Hash string `json:"hash"`
TimeStamp int64 `json:"timestamp"`
Ip string `json:"ip"`
Url string `json:"url"`
Delete string `json:"delete"`
}
使用方法,请查看 example 目录下面的例子
有疑问加站长微信联系(非本文作者)
