mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-16 19:32:27 +08:00
使用github的七牛SDK,配置名称Kodo->Qiniu
This commit is contained in:
34
vendor/github.com/qiniu/api.v7/examples/rs_prefetch.go
generated
vendored
Normal file
34
vendor/github.com/qiniu/api.v7/examples/rs_prefetch.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
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)
|
||||
|
||||
key := "qiniu.png"
|
||||
err := bucketManager.Prefetch(bucket, key)
|
||||
if err != nil {
|
||||
fmt.Println("fetch error,", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user