| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package osssvr
- import (
- "path/filepath"
- "testing"
- "git.wenlab.co/joe/kettle/oss"
- "github.com/qiniu/go-sdk/v7/storage"
- )
- const (
- AK = "SneSBtnWLdStBhCx0O_QogNkXoRlKNOiv1--XMBB"
- CK = "GXMg-ENcp2UKYQWdeaf43tk_06NnMoA4OVFxdkYw"
- )
- func TestQiniuOss_UploadFile(t *testing.T) {
- qn := NewQiniuOss(AK, CK, "playerdna-net",
- WithRegion(storage.RIDHuadong))
- abs, err := filepath.Abs("./a.png")
- if err != nil {
- t.Fatal(err)
- }
- h, err := qn.UploadFile(abs, "a.png", nil)
- if err != nil {
- t.Fatal(err)
- }
- t.Log(h)
- h, err = qn.UploadFile(abs, "a.png", &oss.UploadConf{Overwrite: true})
- if err != nil {
- t.Fatal(err)
- }
- t.Log(h)
- }
- func TestQiniuOss_Exists(t *testing.T) {
- qn := NewQiniuOss(AK, CK, "playerdna-net",
- WithRegion(storage.RIDHuadong))
- yes := qn.Exists("a.png")
- if !yes {
- t.Fatal("should exists a.png")
- }
- yes = qn.Exists("c.png")
- if yes {
- t.Fatal("should not exists c.png")
- }
- //delete
- err := qn.Delete("a.png")
- if err != nil {
- t.Fatal(err)
- }
- yes = qn.Exists("a.png")
- if yes {
- t.Fatal("should not exists a.png")
- }
- }
|