mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
使用github的七牛SDK,配置名称Kodo->Qiniu
This commit is contained in:
33
vendor/github.com/qiniu/api.v7/examples/rs_download.go
generated
vendored
Normal file
33
vendor/github.com/qiniu/api.v7/examples/rs_download.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"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)
|
||||
|
||||
// 公开空间访问
|
||||
domain := "https://image.example.com"
|
||||
key := "这是一个测试文件.jpg"
|
||||
publicAccessURL := storage.MakePublicURL(domain, key)
|
||||
fmt.Println(publicAccessURL)
|
||||
|
||||
// 私有空间访问
|
||||
domain = "https://image.example.com"
|
||||
key = "这是一个测试文件.jpg"
|
||||
deadline := time.Now().Add(time.Second * 3600).Unix() //1小时有效期
|
||||
privateAccessURL := storage.MakePrivateURL(mac, domain, key, deadline)
|
||||
fmt.Println(privateAccessURL)
|
||||
}
|
||||
Reference in New Issue
Block a user