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

I have a code that lists keys with ListObjectsPagesContentsKeyand copies these keys with CopyObject. This works in general, but for some keys that he complains about, the NoSuchKey: The specified key does not exist.set of keys he complains about includes keys with +.

Oddly enough, if I use the CLI: aws s3 cpon "foo + bar", the copy works. But I can not use the CLI. I need to use sdk.

I am using v1.8.11

As Raifen mentioned, plus symbols can be the result of a space change.

Update: Everything is hashed here https://github.com/aws/aws-sdk-go/issues/1438 . Raifen was right about the need QueryEscape. I am going to award the only current answer using the bounty, as it adds useful information, but does not select it as the correct one.

+4
source share
2 answers

This is the details of what was happening: https://github.com/aws/aws-sdk-go/issues/1438

  • The main problem was that it CopySourceshould be encoded in the url and not in the field Key, which was surprising to me. (I was url encoded as.)
  • , path.Join, \. , s3 trailing \ - .
0

:

:

  • - [0-9a-zA-Z]
  • !, -, _, ., *, ', ( )

+ , ", " , ":" , QueryUnescape ( +).

, , : ( ), @ = ( ;), , ?.

, , , QueryUnescape, + ':' : "unescaped".

+1

Source: https://habr.com/ru/post/1682347/


All Articles