1 Star 0 Fork 1

freely随意 / BaiduPCS-Go

forked from ttpc2008 / BaiduPCS-Go 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
quota.go 751 Bytes
一键复制 编辑 原始数据 按行查看 历史
konica 提交于 2018-04-19 22:21 . 优化代码结构
package baidupcs
import (
"github.com/json-iterator/go"
)
type quotaInfo struct {
*ErrInfo
Quota int64 `json:"quota"`
Used int64 `json:"used"`
}
// QuotaInfo 获取当前用户空间配额信息
func (pcs *BaiduPCS) QuotaInfo() (quota, used int64, pcsError Error) {
dataReadCloser, pcsError := pcs.PrepareQuotaInfo()
if pcsError != nil {
return
}
defer dataReadCloser.Close()
quotaInfo := &quotaInfo{
ErrInfo: NewErrorInfo(OperationQuotaInfo),
}
d := jsoniter.NewDecoder(dataReadCloser)
err := d.Decode(quotaInfo)
if err != nil {
quotaInfo.ErrInfo.jsonError(err)
return 0, 0, quotaInfo.ErrInfo
}
if quotaInfo.ErrCode != 0 {
return 0, 0, quotaInfo.ErrInfo
}
quota = quotaInfo.Quota
used = quotaInfo.Used
return
}
1
https://gitee.com/freelysuiyi/BaiduPCS-Go.git
git@gitee.com:freelysuiyi/BaiduPCS-Go.git
freelysuiyi
BaiduPCS-Go
BaiduPCS-Go
v3.5.1

搜索帮助