发布 golang版本的 sm.ms图床API

sndnvaps · 2018-05-06 12:53:36 · 2717 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2018-05-06 12:53:36 的主题,其中的信息可能已经有所发展或是发生改变。

经过查找 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

支持如下功能

Upload

Delete

ListHistory

函数原型

  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 目录下面的例子


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2717 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传