add storages
This commit is contained in:
@@ -5,31 +5,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"backend/database/fields"
|
||||
"backend/database/models/qvyun_v2/public/model"
|
||||
)
|
||||
|
||||
func Build(m *model.Storages) Storage {
|
||||
switch m.Type {
|
||||
case fields.StorageTypeLocal:
|
||||
return &Local{
|
||||
Host: m.Config.Local.Host,
|
||||
Path: m.Config.Local.Path,
|
||||
}
|
||||
case fields.StorageTypeS3:
|
||||
return &S3{
|
||||
Endpoint: m.Config.S3.Endpoint,
|
||||
AccessKeyID: m.Config.S3.AccessKeyID,
|
||||
AccessKeySecret: m.Config.S3.AccessKeySecret,
|
||||
BucketName: m.Config.S3.BucketName,
|
||||
Path: m.Config.S3.Path,
|
||||
}
|
||||
default:
|
||||
panic("invalid storage type")
|
||||
}
|
||||
}
|
||||
|
||||
type Storage interface {
|
||||
Save(ctx context.Context, file *UploadedFile) (*UploadedFile, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user