🚧 under development
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
COMMENT_IMAGES = "comment_images"
|
||||
)
|
@@ -2,11 +2,12 @@ package constant
|
||||
|
||||
// 用户相关的redis key
|
||||
const (
|
||||
UserClientPrefix string = "user:client:"
|
||||
UserCaptchaPrefix string = "user:captcha:"
|
||||
UserTokenPrefix string = "user:token:"
|
||||
UserSmsRedisPrefix string = "user:sms:"
|
||||
UserQrcodePrefix = "user:qrcode:"
|
||||
UserClientPrefix string = "user:client:"
|
||||
UserCaptchaPrefix string = "user:captcha:"
|
||||
UserTokenPrefix string = "user:token:"
|
||||
UserSmsRedisPrefix string = "user:sms:"
|
||||
UserQrcodePrefix = "user:qrcode:"
|
||||
UserOssConfigPrefix = "user:oss:"
|
||||
)
|
||||
|
||||
// 系统相关的redis key
|
||||
@@ -18,3 +19,8 @@ const (
|
||||
FaceSamplePrefix = "face:samples:"
|
||||
FaceVectorPrefix = "face:vectors:"
|
||||
)
|
||||
|
||||
const (
|
||||
ImageListPrefix = "image:list:"
|
||||
ImageListMetaPrefix = "image:meta:"
|
||||
)
|
||||
|
@@ -13,6 +13,7 @@ import (
|
||||
"schisandra-album-cloud-microservices/common/storage/config"
|
||||
"schisandra-album-cloud-microservices/common/storage/events"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AliOSS struct {
|
||||
@@ -400,5 +401,19 @@ func (a *AliOSS) RenameObject(ctx context.Context, destBucketName, destObjectNam
|
||||
return -1, fmt.Errorf("failed to delete object, error: %v", err)
|
||||
}
|
||||
return deleteResult.StatusCode, nil
|
||||
|
||||
}
|
||||
|
||||
// PresignedURL 生成预签名URL
|
||||
func (a *AliOSS) PresignedURL(ctx context.Context, bucketName, objectKey string, expires time.Duration) (string, error) {
|
||||
|
||||
// 生成预签名URL
|
||||
presignedResult, err := a.client.Presign(ctx, &oss.GetObjectRequest{
|
||||
Bucket: oss.Ptr(bucketName),
|
||||
Key: oss.Ptr(objectKey),
|
||||
}, oss.PresignExpires(expires))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to generate presigned URL, error: %v", err)
|
||||
}
|
||||
|
||||
return presignedResult.URL, nil
|
||||
}
|
||||
|
@@ -74,4 +74,5 @@ type Service interface {
|
||||
ListObjects(ctx context.Context, bucketName string, maxKeys int32) ([]ObjectProperties, error)
|
||||
DeleteObject(ctx context.Context, bucketName, objectName string) (int, error)
|
||||
RenameObject(ctx context.Context, destBucketName, destObjectName, srcObjectName, srcBucketName string) (int, error)
|
||||
PresignedURL(ctx context.Context, bucketName, objectKey string, expires time.Duration) (string, error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user