mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
Merge pull request #32 from eiblog/qiniu_zone
qiniu upload remove zone, support all zone upload
This commit is contained in:
@@ -42,7 +42,6 @@ func QiniuUpload(params UploadParams) (string, error) {
|
||||
uploadToken := putPolicy.UploadToken(mac)
|
||||
// 上传配置
|
||||
cfg := &storage.Config{
|
||||
Zone: &storage.ZoneHuadong,
|
||||
UseHTTPS: true,
|
||||
}
|
||||
// uploader
|
||||
|
||||
47
pkg/internal/qiniu_test.go
Normal file
47
pkg/internal/qiniu_test.go
Normal 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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user