feat: update ali oss client
This commit is contained in:
27
backend/providers/ali/oss_client.go
Normal file
27
backend/providers/ali/oss_client.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package ali
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
|
||||
)
|
||||
|
||||
type OSSClient struct {
|
||||
client *oss.Client
|
||||
config *Config
|
||||
}
|
||||
|
||||
func (c *OSSClient) GetClient() *oss.Client {
|
||||
return c.client
|
||||
}
|
||||
|
||||
func (c *OSSClient) PreSignUpload(ctx context.Context, path string) (*oss.PresignResult, error) {
|
||||
request := &oss.PutObjectRequest{
|
||||
Bucket: oss.Ptr(c.config.Bucket),
|
||||
Key: oss.Ptr("quyun/" + strings.Trim(path, "/")),
|
||||
}
|
||||
log.Printf("%+v", request)
|
||||
return c.client.Presign(ctx, request)
|
||||
}
|
||||
Reference in New Issue
Block a user