添加本地上传的功能
This commit is contained in:
@@ -653,14 +653,16 @@ func (f *Factory) getStorage() (storage.Storage, error) {
|
||||
}
|
||||
|
||||
// 根据配置自动选择存储类型
|
||||
// 优先级:MinIO > OSS
|
||||
// 优先级:Local > MinIO > OSS
|
||||
var storageType storage.StorageType
|
||||
if f.cfg.MinIO != nil {
|
||||
if f.cfg.GetLocalStorage() != nil {
|
||||
storageType = storage.StorageTypeLocal
|
||||
} else if f.cfg.MinIO != nil {
|
||||
storageType = storage.StorageTypeMinIO
|
||||
} else if f.cfg.OSS != nil {
|
||||
storageType = storage.StorageTypeOSS
|
||||
} else {
|
||||
return nil, fmt.Errorf("no storage config found (OSS or MinIO)")
|
||||
return nil, fmt.Errorf("no storage config found (LocalStorage, OSS or MinIO)")
|
||||
}
|
||||
|
||||
// 创建存储实例
|
||||
@@ -673,6 +675,16 @@ func (f *Factory) getStorage() (storage.Storage, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// GetStorage 获取存储实例对象(高级功能时使用)
|
||||
// 通常推荐使用黑盒方法:
|
||||
// - UploadFile()
|
||||
// - GetFileURL()
|
||||
//
|
||||
// 如需自定义上传/查看行为(例如 Delete/Exists/GetObject),可使用此方法获取底层存储对象。
|
||||
func (f *Factory) GetStorage() (storage.Storage, error) {
|
||||
return f.getStorage()
|
||||
}
|
||||
|
||||
// UploadFile 上传文件(黑盒模式,推荐使用)
|
||||
// 自动根据配置选择存储类型(OSS 或 MinIO),无需关心内部实现
|
||||
// ctx: 上下文
|
||||
|
||||
Reference in New Issue
Block a user