添加本地上传的功能

This commit is contained in:
2026-01-30 21:40:21 +08:00
parent 38ebe73e45
commit a6e8101e09
16 changed files with 531 additions and 58 deletions

View File

@@ -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: 上下文