How to list and copy s3 keys with non alphanumeric characters?

Viewed 521

I have code which lists keys using ListObjectsPages->Contents->Key and copies those keys using CopyObject. This works in general but for some keys it's complaining NoSuchKey: The specified key does not exist. The set of keys it's complaining about include keys with +.

Oddly, if I use the CLI: aws s3 cp on "foo+bar", the copy works. But I can't use the CLI. I need to use the sdk.

I'm using v1.8.11

As Rayfen mentioned, the plus characters could be the result of space replacement.

Update: Everything was hashed out here https://github.com/aws/aws-sdk-go/issues/1438. Rayfen was right about needing to QueryEscape. I'm going to award the only current answer with the bounty since it adds useful information, but not select it as correct.

2 Answers
Related