fix(oss): 禁用OSS S3兼容API的自动校验和计算,修复签名不匹配问题并调整路径样式设置

This commit is contained in:
bingxiang.cheng
2026-04-13 14:51:56 +08:00
parent 00a09d6c56
commit 12001f23bf
+1 -5
View File
@@ -39,10 +39,6 @@ func newOSSClient(endpoint, region, accessKey, secretKey string) (*s3.Client, er
cfg, err := config.LoadDefaultConfig(context.Background(), cfg, err := config.LoadDefaultConfig(context.Background(),
config.WithRegion(region), config.WithRegion(region),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")),
// OSS S3-compatible API does not support AWS-specific checksum headers.
// Disable automatic checksum calculation/validation to prevent signature mismatch (403).
config.WithRequestChecksumCalculation(aws.RequestChecksumCalculationWhenRequired),
config.WithResponseChecksumValidation(aws.ResponseChecksumValidationWhenRequired),
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load AWS config: %w", err) return nil, fmt.Errorf("failed to load AWS config: %w", err)
@@ -50,7 +46,7 @@ func newOSSClient(endpoint, region, accessKey, secretKey string) (*s3.Client, er
client := s3.NewFromConfig(cfg, func(o *s3.Options) { client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(endpoint) o.BaseEndpoint = aws.String(endpoint)
o.UsePathStyle = true o.UsePathStyle = false
}) })
return client, nil return client, nil