aws-sdk-go: service/s3: Metadata returns uppercase character
In the console:
When I do:
result, err := c.HeadObject(&s3.HeadObjectInput{
Bucket: aws.String("xxx"),
Key: aws.String("xxx"),
})
fmt.Printf("%#v\n", result)
I get:
...
{
AcceptRanges: "bytes",
ContentLength: 0,
ContentType: "binary/octet-stream",
ETag: "\"d41d8cd98f00b204e9800998ecf8427e\"",
LastModified: 2015-11-18 19:00:42 +0000 UTC,
Metadata: {
Lp2: "87adaa3c-0bab-4808-a05b-cfe79ba23714"
}
}
...
Please note Lp2
. I would assume it returns lp2
. Is this expected?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 9
- Comments: 17 (6 by maintainers)
Please note that this issue still persists more than two years after it was originally opened. I would consider this a bug rather than a Feature Request - different casing is unexpected behavior and requires additional code as a workaround.
Hi, guys. Actually, you can use
LowerCaseHeaderMaps
to do this trick now. From the aws/config.go:But there was a bug in this feature, and the PR #3671 fixed this.
Amazon metadata for S3 is case insensitive on the keys, but the Golang SDK is weird. The unmarshalHeaderMap method always returns the canonical header key form. So enable
LowerCaseHeaderMaps
config will return the lower case key form. You can check this test private/protocol/rest/rest_test.go to see how it works.Cheers.
Ping.
This is definitely a bug, not a feature-request. Still there in 1.29.21.
What makes it even more confusing is that if you set the metadata for example via PutObjectInput the keys will always be set as all lowercase.
still an issue with v1.20.2 😦
the problem still not solved, using version: v1.16.26 😕
@mattes The SDK will automatically case the metadata fields to Go net/http’s standard header canonical formating. The issue we’re seeing here is the service’s implementation details of the metadata fields being transmitted via headers bleeding into how the SDK returns them.
This issue could be addressed and maintain backwards compatibility by introducing an option to ensure the metadata parameters maintain their original casing. Instead of using Go’s canonical header key format.