예제 #1
0
파일: demo.go 프로젝트: needkane/qiniu
//download
func downloadUrl(domain, key string) string {
	baseUrl := rs.MakeBaseUrl(domain, key)
	//baseUrl = baseUrl + "?pm3u8/0/e/1438162783"
	baseUrl = baseUrl + "?avinfo"
	policy := rs.GetPolicy{}
	return policy.MakeRequest(baseUrl, nil)
}
예제 #2
0
func TestPrivateImageView(t *testing.T) {

	//首先上传一个图片 用于测试
	policy := rs.PutPolicy{
		Scope: bucket + ":" + key,
	}
	err := io.PutFile(nil, nil, policy.Token(nil), key, localFile, nil)
	if err != nil {
		t.Errorf("TestPrivateImageView failed: %v", err)
		return
	}

	rawUrl := makeUrl(key)

	iv := ImageView{
		Mode:    2,
		Height:  250,
		Quality: 80,
	}
	imageViewUrl := iv.MakeRequest(rawUrl)
	p := rs.GetPolicy{}
	imageViewUrlWithToken := p.MakeRequest(imageViewUrl, nil)
	resp, err := http.DefaultClient.Get(imageViewUrlWithToken)
	if err != nil {
		t.Errorf("TestPrivateImageView failed: %v", err)
		return
	}
	defer resp.Body.Close()

	if (resp.StatusCode / 100) != 2 {
		t.Errorf("TestPrivateImageView failed: resp.StatusCode = %v", resp.StatusCode)
		return
	}
}
예제 #3
0
파일: main.go 프로젝트: yunan/Go-Example
func handleReturn(w http.ResponseWriter, req *http.Request) {

	ret := req.FormValue("upload_ret")
	b, err := base64.URLEncoding.DecodeString(ret)
	if err != nil {
		w.WriteHeader(404)
		return
	}

	var uploadRet UploadRet
	err = json.Unmarshal(b, &uploadRet)
	if err != nil {
		w.WriteHeader(404)
		return
	}

	policy := rs.GetPolicy{Scope: "*/" + uploadRet.Key}
	img := policy.MakeRequest(rs.MakeBaseUrl(DOMAIN, uploadRet.Key))
	returnPage := fmt.Sprintf(returnPageFmt, string(b), img, img)
	w.Write([]byte(returnPage))
}
예제 #4
0
파일: qiniu.go 프로젝트: gavinzhs/testgo
func downloadUrl(domain, key string) string {
	baseUrl := rs.MakeBaseUrl(domain, key)
	policy := rs.GetPolicy{}
	return policy.MakeRequest(baseUrl, mac)
}
예제 #5
0
파일: qiniu.go 프로젝트: trigrass2/wego
func GetQiniuPrivateDownloadUrl(domain, key string) string {
	baseUrl := rs.MakeBaseUrl(domain, key)
	policy := rs.GetPolicy{}
	return policy.MakeRequest(baseUrl, nil)
}
예제 #6
0
파일: qiniu.go 프로젝트: wxaxiaoyao/linux
func GetUrl(key string) string {
	baseUrl := rs.MakeBaseUrl(DOWNLOAD_URL, key)
	getPolicy := rs.GetPolicy{}
	return getPolicy.MakeRequest(baseUrl, nil)
}