package osssvr import ( "github.com/qiniu/go-sdk/v7/storage" "one.com/kettle/oss" "path/filepath" "testing" ) 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") } }