mirror of
https://github.com/versity/versitygw.git
synced 2026-01-08 12:41:10 +00:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user