2024-05-30 18:40:57 +08:00
|
|
|
package oss
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUpload_Put(t *testing.T) {
|
|
|
|
req := CreatePutOssRequest()
|
|
|
|
req.BucketName = "image"
|
|
|
|
file, err := os.ReadFile("test.jpg")
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
req.FileStream = file
|
|
|
|
client, err := NewClient()
|
|
|
|
resp, err := client.PutOss(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Log(resp.Data.Url)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpload_Del(t *testing.T) {
|
|
|
|
req := CreateDelOssRequest()
|
|
|
|
req.BucketName = "image"
|
|
|
|
req.MediaUrl = "https://image.89yoo.com/uploads/549/549e887460a72333c361661683023018.jpeg"
|
|
|
|
client, err := NewClient()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := client.DelOss(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Log(resp.Code)
|
|
|
|
}
|
2024-07-17 14:50:29 +08:00
|
|
|
|
|
|
|
func TestCreateInitMultipartUpload(t *testing.T) {
|
|
|
|
req := CreateInitMultipartUploadRequest()
|
|
|
|
req.Filepath = "test.jpg"
|
|
|
|
req.TargetType = "oss"
|
|
|
|
req.TargetName = "image"
|
|
|
|
client, err := NewClient()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := client.InitMultipartUpload(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Log(resp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClient_GetApkVersion(t *testing.T) {
|
|
|
|
req := CreateGetApkVersionRequest()
|
|
|
|
req.Filepath = "36c55c4c3a2f4c79e3917b989d580496.zip"
|
|
|
|
client, err := NewClient()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := client.GetApkVersion(req)
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Log(resp.Data.VersionCode, resp.Data.VersionName)
|
|
|
|
}
|