22 lines
569 B
Go
22 lines
569 B
Go
|
|
package factory
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
|
||
|
|
"git.apinb.com/ops/files/internal/config"
|
||
|
|
"git.apinb.com/ops/files/internal/storage"
|
||
|
|
"git.apinb.com/ops/files/internal/storage/aliyun"
|
||
|
|
"git.apinb.com/ops/files/internal/storage/local"
|
||
|
|
)
|
||
|
|
|
||
|
|
func New(storageConfig config.StorageConf) (storage.Backend, error) {
|
||
|
|
switch storageConfig.Provider {
|
||
|
|
case "local":
|
||
|
|
return local.New(storageConfig)
|
||
|
|
case "aliyun":
|
||
|
|
return aliyun.New(storageConfig.Aliyun, storageConfig.AccessTTLSeconds)
|
||
|
|
default:
|
||
|
|
return nil, fmt.Errorf("不支持的文件存储类型: %s", storageConfig.Provider)
|
||
|
|
}
|
||
|
|
}
|