feat(storage): 集成S3存储适配器

添加对AWS S3及兼容存储服务的支持:
- 实现完整的S3FileService接口
- 支持文件上传、下载、删除功能
- 添加配置支持和环境变量检查
- 实现连接测试功能
- 遵循与其他存储适配器相同的代码风格
This commit is contained in:
DaWesen
2026-03-07 14:01:22 +08:00
committed by lyingbug
parent e898d62141
commit e309e0bed8
10 changed files with 496 additions and 5 deletions
@@ -90,6 +90,16 @@ func NewFileServiceFromStorageConfig(
}
svc, err := NewTosFileService(sec.TOS.Endpoint, sec.TOS.Region, sec.TOS.AccessKey, sec.TOS.SecretKey, sec.TOS.BucketName, sec.TOS.PathPrefix)
return svc, p, err
case "s3":
if sec == nil || sec.S3 == nil || sec.S3.Endpoint == "" || sec.S3.Region == "" || sec.S3.AccessKey == "" || sec.S3.SecretKey == "" || sec.S3.BucketName == "" {
return nil, p, fmt.Errorf("incomplete s3 config")
}
pathPrefix := strings.TrimSpace(sec.S3.PathPrefix)
if pathPrefix == "" {
pathPrefix = "weknora/"
}
svc, err := NewS3FileService(sec.S3.Endpoint, sec.S3.AccessKey, sec.S3.SecretKey, sec.S3.BucketName, sec.S3.Region, pathPrefix)
return svc, p, err
default:
return nil, p, fmt.Errorf("unsupported provider %q", p)