github.com/qjfoidnh/BaiduPCS-Go@v0.0.0-20231011165705-caa18a3765f3/baidupcs/quota.go (about) 1 package baidupcs 2 3 import ( 4 "github.com/qjfoidnh/BaiduPCS-Go/baidupcs/pcserror" 5 ) 6 7 type quotaInfo struct { 8 *pcserror.PCSErrInfo 9 Quota int64 `json:"quota"` 10 Used int64 `json:"used"` 11 } 12 13 // QuotaInfo 获取当前用户空间配额信息 14 func (pcs *BaiduPCS) QuotaInfo() (quota, used int64, pcsError pcserror.Error) { 15 dataReadCloser, pcsError := pcs.PrepareQuotaInfo() 16 if pcsError != nil { 17 return 18 } 19 20 defer dataReadCloser.Close() 21 22 quotaInfo := "aInfo{ 23 PCSErrInfo: pcserror.NewPCSErrorInfo(OperationQuotaInfo), 24 } 25 26 pcsError = pcserror.HandleJSONParse(OperationQuotaInfo, dataReadCloser, quotaInfo) 27 if pcsError != nil { 28 return 29 } 30 31 return quotaInfo.Quota, quotaInfo.Used, nil 32 }