Esempio n. 1
0
func (p *Client) MakeUptoken(policy *PutPolicy) string {

	var rr = *policy
	if rr.Expires == 0 {
		rr.Expires = 3600
	}
	rr.Expires += uint32(time.Now().Unix())
	b, _ := json.Marshal(&rr)
	return qbox.SignWithData(p.mac, b)
}
Esempio n. 2
0
func (p *Client) MakeUptokenWithSafe(policy *PutPolicy) (token string, err error) {
	var rr = *policy
	if len(rr.UpHosts) == 0 {
		bucketName := getBucketNameFromPutPolicy(policy)
		bucketInfo, err1 := p.GetBucketInfo(bucketName)
		if err1 != nil {
			err = err1
			return
		}
		rr.UpHosts = bucketInfo.UpHosts
	}
	if rr.Expires == 0 {
		rr.Expires = 3600
	}
	rr.Expires += uint32(time.Now().Unix())
	b, _ := json.Marshal(&rr)
	token = qbox.SignWithData(p.mac, b)
	return
}