添加本地上传的功能
This commit is contained in:
@@ -39,10 +39,11 @@ type StorageType string
|
||||
const (
|
||||
StorageTypeOSS StorageType = "oss"
|
||||
StorageTypeMinIO StorageType = "minio"
|
||||
StorageTypeLocal StorageType = "local"
|
||||
)
|
||||
|
||||
// NewStorage 创建存储实例
|
||||
// storageType: 存储类型(oss或minio)
|
||||
// storageType: 存储类型(oss/minio/local)
|
||||
// cfg: 配置对象
|
||||
func NewStorage(storageType StorageType, cfg *config.Config) (Storage, error) {
|
||||
switch storageType {
|
||||
@@ -58,6 +59,12 @@ func NewStorage(storageType StorageType, cfg *config.Config) (Storage, error) {
|
||||
return nil, fmt.Errorf("MinIO config is nil")
|
||||
}
|
||||
return NewMinIOStorage(minioConfig)
|
||||
case StorageTypeLocal:
|
||||
localCfg := cfg.GetLocalStorage()
|
||||
if localCfg == nil {
|
||||
return nil, fmt.Errorf("LocalStorage config is nil")
|
||||
}
|
||||
return NewLocalStorage(localCfg)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported storage type: %s", storageType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user