阿里云oss
This commit is contained in:
@@ -36,8 +36,8 @@ func (c *ALiYunOSSClient) NewAliYunOSS() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPutSignUrl 获取上传签名
|
||||
func (c *ALiYunOSSClient) GetPutSignUrl(bucket string, key string, expires time.Duration) (result *oss.PresignResult, err error) {
|
||||
// BuildPutSignUrl 获取上传签名
|
||||
func (c *ALiYunOSSClient) BuildPutSignUrl(bucket string, key string, expires time.Duration) (result *oss.PresignResult, err error) {
|
||||
// 生成PutObject的预签名URL
|
||||
result, err = c.ossClient.Presign(
|
||||
context.Background(),
|
||||
@@ -53,8 +53,8 @@ func (c *ALiYunOSSClient) GetPutSignUrl(bucket string, key string, expires time.
|
||||
return
|
||||
}
|
||||
|
||||
// GetPutSignUrlByPutObjectRequest 根据PutObjectRequest生成PutObject的预签名URL
|
||||
func (c *ALiYunOSSClient) GetPutSignUrlByPutObjectRequest(req *oss.PutObjectRequest, expires time.Duration) (result *oss.PresignResult, err error) {
|
||||
// BuildPutSignUrlByPutObjectRequest 根据PutObjectRequest生成PutObject的预签名URL
|
||||
func (c *ALiYunOSSClient) BuildPutSignUrlByPutObjectRequest(req *oss.PutObjectRequest, expires time.Duration) (result *oss.PresignResult, err error) {
|
||||
// 生成PutObject的预签名URL
|
||||
result, err = c.ossClient.Presign(
|
||||
context.Background(),
|
||||
@@ -67,8 +67,8 @@ func (c *ALiYunOSSClient) GetPutSignUrlByPutObjectRequest(req *oss.PutObjectRequ
|
||||
return
|
||||
}
|
||||
|
||||
// GetSignUrlByGetObjectRequest 根据GetObjectRequest生成GetObject的预签名URL
|
||||
func (c *ALiYunOSSClient) GetSignUrlByGetObjectRequest(req *oss.GetObjectRequest) (result *oss.PresignResult, err error) {
|
||||
// BuildSignUrlByGetObjectRequest 根据GetObjectRequest生成GetObject的预签名URL
|
||||
func (c *ALiYunOSSClient) BuildSignUrlByGetObjectRequest(req *oss.GetObjectRequest) (result *oss.PresignResult, err error) {
|
||||
// 生成PutObject的预签名URL
|
||||
result, err = c.ossClient.Presign(
|
||||
context.Background(),
|
||||
|
@@ -25,19 +25,19 @@ func TestALiYunOSSClient_NewAliYunOSS(t *testing.T) {
|
||||
t.Log(client.ossClient)
|
||||
}
|
||||
|
||||
func TestALiYunOSSClient_GetSignUrl(t *testing.T) {
|
||||
func TestALiYunOSSClient_BuildPutSignUrl(t *testing.T) {
|
||||
err := client.NewAliYunOSS()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sign, err := client.GetPutSignUrl("", "test/upload/bizhi1.jpg", 0)
|
||||
sign, err := client.BuildPutSignUrl("", "test/upload/bizhi1.jpg", 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Log(sign)
|
||||
}
|
||||
|
||||
func TestALiYunOSSClient_GetSignUrlByPutObjectRequest(t *testing.T) {
|
||||
func TestALiYunOSSClient_BuildPutSignUrlByPutObjectRequest(t *testing.T) {
|
||||
err := client.NewAliYunOSS()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -46,7 +46,7 @@ func TestALiYunOSSClient_GetSignUrlByPutObjectRequest(t *testing.T) {
|
||||
req.Bucket = oss.Ptr("")
|
||||
req.Key = oss.Ptr("test/upload/bizhi2.jpg")
|
||||
req.ContentType = oss.Ptr("application/octet-stream")
|
||||
sign, err := client.GetPutSignUrlByPutObjectRequest(req, 0)
|
||||
sign, err := client.BuildPutSignUrlByPutObjectRequest(req, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func TestALiYunOSSClient_PutForLocalFile(t *testing.T) {
|
||||
t.Log(result)
|
||||
}
|
||||
|
||||
func TestALiYunOSSClient_GetSignUrlByGetObjectRequest(t *testing.T) {
|
||||
func TestALiYunOSSClient_BuildSignUrlByGetObjectRequest(t *testing.T) {
|
||||
err := client.NewAliYunOSS()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -73,7 +73,7 @@ func TestALiYunOSSClient_GetSignUrlByGetObjectRequest(t *testing.T) {
|
||||
req := &oss.GetObjectRequest{}
|
||||
req.Bucket = oss.Ptr("ssgfdown")
|
||||
req.Key = oss.Ptr("test/upload/bizhi2.jpg")
|
||||
result, err := client.GetSignUrlByGetObjectRequest(req)
|
||||
result, err := client.BuildSignUrlByGetObjectRequest(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user