예제 #1
0
func (vc *VideoCloud) DownloadWithSign(userid string, fileid string, filename string) error {

	reqUrl := fmt.Sprintf("http://%d.%s/%d/%s/%s/original", vc.Appid, QCLOUD_VIDEO_DOWNLOAD_DOMAIN, vc.Appid, userid, fileid)
	sign, err := sign.AppSignOnce(vc.Appid, vc.SecretId, vc.SecretKey, userid, fileid)
	if nil != err {
		return err
	}

	return vc.DownloadByUrl(reqUrl+"?sign="+sign, filename)
}
예제 #2
0
func (vc *VideoCloud) Delete(userid string, fileid string) error {
	reqUrl := fmt.Sprintf("http://%s/%d/%s/%s/del", QCLOUD_VIDEO_DOMAIN, vc.Appid, userid, fileid)
	sign, err := sign.AppSignOnce(vc.Appid, vc.SecretId, vc.SecretKey, userid, fileid)
	if nil != err {
		return err
	}

	req, err := http.NewRequest("POST", reqUrl, nil)
	if nil != err {
		return err
	}
	req.Header.Set("HOST", "web.video.myqcloud.com")
	req.Header.Set("user-agent", "qcloud-go-sdk")
	req.Header.Set("Authorization", sign)

	var client http.Client
	resp, err := client.Do(req)
	defer resp.Body.Close()
	if nil != err {
		return err
	}

	data, err := ioutil.ReadAll(resp.Body)
	if nil != err {
		return err
	}

	code, message, _, err := vc.parseRsp(data)
	if nil != err {
		return err
	}
	if code != 0 {
		desc := fmt.Sprintf("rsp error, code=%d, message=%s", code, message)
		return errors.New(desc)
	}

	return nil
}
예제 #3
0
func (vc *VideoCloud) SignOnce(userid string, fileid string) (string, error) {
	return sign.AppSignOnce(vc.Appid, vc.SecretId, vc.SecretKey, userid, fileid)
}