feat(storage): 集成S3存储适配器
添加对AWS S3及兼容存储服务的支持: - 实现完整的S3FileService接口 - 支持文件上传、下载、删除功能 - 添加配置支持和环境变量检查 - 实现连接测试功能 - 遵循与其他存储适配器相同的代码风格
This commit is contained in:
@@ -534,6 +534,26 @@ func initFileService(cfg *config.Config) (interfaces.FileService, error) {
|
||||
os.Getenv("TOS_TEMP_BUCKET_NAME"), // 可选:临时桶名称(桶需配置生命周期规则自动过期)
|
||||
os.Getenv("TOS_TEMP_REGION"), // 可选:临时桶 region,默认与主桶相同
|
||||
)
|
||||
case "s3":
|
||||
if os.Getenv("S3_ENDPOINT") == "" ||
|
||||
os.Getenv("S3_REGION") == "" ||
|
||||
os.Getenv("S3_ACCESS_KEY") == "" ||
|
||||
os.Getenv("S3_SECRET_KEY") == "" ||
|
||||
os.Getenv("S3_BUCKET_NAME") == "" {
|
||||
return nil, fmt.Errorf("missing S3 configuration")
|
||||
}
|
||||
pathPrefix := os.Getenv("S3_PATH_PREFIX")
|
||||
if pathPrefix == "" {
|
||||
pathPrefix = "weknora/"
|
||||
}
|
||||
return file.NewS3FileService(
|
||||
os.Getenv("S3_ENDPOINT"),
|
||||
os.Getenv("S3_ACCESS_KEY"),
|
||||
os.Getenv("S3_SECRET_KEY"),
|
||||
os.Getenv("S3_BUCKET_NAME"),
|
||||
os.Getenv("S3_REGION"),
|
||||
pathPrefix,
|
||||
)
|
||||
case "local":
|
||||
baseDir := os.Getenv("LOCAL_STORAGE_BASE_DIR")
|
||||
if baseDir == "" {
|
||||
|
||||
Reference in New Issue
Block a user