Browse Source

支持通用的S3存储

feature_wq
Sydonian 9 months ago
parent
commit
28882af18f
2 changed files with 35 additions and 0 deletions
  1. +15
    -0
      sdks/storage/public_storage.go
  2. +20
    -0
      sdks/storage/storage.go

+ 15
- 0
sdks/storage/public_storage.go View File

@@ -15,6 +15,7 @@ type PublicStoreConfig interface {

var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[PublicStoreConfig](
(*LocalPublicStorage)(nil),
(*S3PublicStorage)(nil),
)), "type")

type LocalPublicStorage struct {
@@ -31,3 +32,17 @@ func (s *LocalPublicStorage) GetPublicStoreType() string {
func (s *LocalPublicStorage) String() string {
return fmt.Sprintf("Local[LoadBase=%v]", s.LoadBase)
}

type S3PublicStorage struct {
serder.Metadata `union:"S3"`
Type string `json:"type"`
LoadBase string `json:"loadBase"`
}

func (s *S3PublicStorage) GetPublicStoreType() string {
return "S3"
}

func (s *S3PublicStorage) String() string {
return fmt.Sprintf("S3[LoadBase=%v]", s.LoadBase)
}

+ 20
- 0
sdks/storage/storage.go View File

@@ -44,6 +44,7 @@ var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[Storage
(*OSSType)(nil),
(*COSType)(nil),
(*EFileType)(nil),
(*S3Type)(nil),
)), "type")

// 多种存储服务的混合存储服务。需谨慎选择存储服务的组合,避免出Bug
@@ -149,3 +150,22 @@ func (a *EFileType) GetStorageType() string {
func (a *EFileType) String() string {
return "EFile"
}

// 通用的S3协议的存储服务
type S3Type struct {
serder.Metadata `union:"S3"`
Type string `json:"type"`
Region string `json:"region"`
AK string `json:"accessKeyId"`
SK string `json:"secretAccessKey"`
Endpoint string `json:"endpoint"`
Bucket string `json:"bucket"`
}

func (a *S3Type) GetStorageType() string {
return "S3"
}

func (a *S3Type) String() string {
return "S3"
}

Loading…
Cancel
Save