本文整理匯總了Golang中github.com/qiniu/api/rs.GetPolicy類的典型用法代碼示例。如果您正苦於以下問題:Golang GetPolicy類的具體用法?Golang GetPolicy怎麽用?Golang GetPolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GetPolicy類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: downloadUrl
//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: TestPrivateImageView
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: handleReturn
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: downloadUrl
func downloadUrl(domain, key string) string {
baseUrl := rs.MakeBaseUrl(domain, key)
policy := rs.GetPolicy{}
return policy.MakeRequest(baseUrl, mac)
}
示例5: GetQiniuPrivateDownloadUrl
func GetQiniuPrivateDownloadUrl(domain, key string) string {
baseUrl := rs.MakeBaseUrl(domain, key)
policy := rs.GetPolicy{}
return policy.MakeRequest(baseUrl, nil)
}
示例6: GetUrl
func GetUrl(key string) string {
baseUrl := rs.MakeBaseUrl(DOWNLOAD_URL, key)
getPolicy := rs.GetPolicy{}
return getPolicy.MakeRequest(baseUrl, nil)
}