fix: makes object metadata keys lowercase in object creation actions

Fixes #1482

The metadata keys should always be converted to lowercase in `PutObject`, `CreateMultipartUpload`, and `CopyObject`. This implementation converts the metadata keys to lowercase in the front end, ensuring they are stored in lowercase in the backend.
This commit is contained in:
niksis02
2025-10-28 21:47:13 +04:00
parent d63b5818f1
commit 045bdec60c
4 changed files with 250 additions and 3 deletions

View File

@@ -535,6 +535,7 @@ func putObjectWithData(lgth int64, input *s3.PutObjectInput, client *s3.Client)
type mpCfg struct {
checksumAlgorithm types.ChecksumAlgorithm
checksumType types.ChecksumType
metadata map[string]string
}
type mpOpt func(*mpCfg)
@@ -545,6 +546,9 @@ func withChecksum(algo types.ChecksumAlgorithm) mpOpt {
func withChecksumType(t types.ChecksumType) mpOpt {
return func(mc *mpCfg) { mc.checksumType = t }
}
func withMetadata(m map[string]string) mpOpt {
return func(mc *mpCfg) { mc.metadata = m }
}
func createMp(s3client *s3.Client, bucket, key string, opts ...mpOpt) (*s3.CreateMultipartUploadOutput, error) {
cfg := new(mpCfg)
@@ -557,6 +561,7 @@ func createMp(s3client *s3.Client, bucket, key string, opts ...mpOpt) (*s3.Creat
Key: &key,
ChecksumAlgorithm: cfg.checksumAlgorithm,
ChecksumType: cfg.checksumType,
Metadata: cfg.metadata,
})
cancel()
return out, err
@@ -710,7 +715,7 @@ func areMapsSame(mp1, mp2 map[string]string) bool {
return false
}
for key, val := range mp2 {
if mp1[strings.ToLower(key)] != val {
if mp1[key] != val {
return false
}
}