使用github的七牛SDK,配置名称Kodo->Qiniu

This commit is contained in:
deepzz0
2017-11-05 12:27:22 +08:00
parent c9fc0cc75a
commit 360204995d
429 changed files with 26939 additions and 14206 deletions

44
vendor/github.com/qiniu/api.v7/examples/rs_fetch.go generated vendored Normal file
View File

@@ -0,0 +1,44 @@
package main
import (
"fmt"
"os"
"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/storage"
)
var (
accessKey = os.Getenv("QINIU_ACCESS_KEY")
secretKey = os.Getenv("QINIU_SECRET_KEY")
bucket = os.Getenv("QINIU_TEST_BUCKET")
)
func main() {
mac := qbox.NewMac(accessKey, secretKey)
cfg := storage.Config{
// 是否使用https域名进行资源管理
UseHTTPS: false,
}
// 指定空间所在的区域,如果不指定将自动探测
// 如果没有特殊需求,默认不需要指定
//cfg.Zone=&storage.ZoneHuabei
bucketManager := storage.NewBucketManager(mac, &cfg)
resURL := "http://devtools.qiniu.com/qiniu.png"
// 指定保存的key
fetchRet, err := bucketManager.Fetch(resURL, bucket, "qiniu.png")
if err != nil {
fmt.Println("fetch error,", err)
} else {
fmt.Println(fetchRet.String())
}
// 不指定保存的key默认用文件hash作为文件名
fetchRet, err = bucketManager.FetchWithoutKey(resURL, bucket)
if err != nil {
fmt.Println("fetch error,", err)
} else {
fmt.Println(fetchRet.String())
}
}