Merge pull request #32 from eiblog/qiniu_zone

qiniu upload remove zone, support all zone upload
This commit is contained in:
Deepzz
2021-08-12 09:19:56 +08:00
committed by GitHub
2 changed files with 47 additions and 1 deletions

View File

@@ -42,7 +42,6 @@ func QiniuUpload(params UploadParams) (string, error) {
uploadToken := putPolicy.UploadToken(mac)
// 上传配置
cfg := &storage.Config{
Zone: &storage.ZoneHuadong,
UseHTTPS: true,
}
// uploader

View File

@@ -0,0 +1,47 @@
// Package internal provides ...
package internal
import (
"os"
"testing"
"time"
"github.com/eiblog/eiblog/pkg/config"
)
func TestQiniuUpload(t *testing.T) {
f, _ := os.Open("qiniu_test.go")
fi, _ := f.Stat()
type args struct {
params UploadParams
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
{"1", args{params: UploadParams{
Name: "test-" + time.Now().Format("200601021504059999") + ".go",
Size: fi.Size(),
Data: f,
Conf: config.Qiniu{
AccessKey: os.Getenv("QINIU_ACCESSKEY"),
SecretKey: os.Getenv("QINIU_SECRETKEY"),
Bucket: os.Getenv("QINIU_BUCKET"),
},
}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := QiniuUpload(tt.args.params)
if (err != nil) != tt.wantErr {
t.Errorf("QiniuUpload() error = %v, wantErr %v", err, tt.wantErr)
return
}
t.Logf("QiniuUpload() = %v", got)
})
}
}