Special characters in the Amazon S3 file name

Users upload files with names such as "ab # 1", "ab # 2". I upload these files to S3. When I try to load these files, I get an error similar to this <Code> InvalidArgumentCode> The header value contains an open quotation mark.

I create the link by wrapping the file name using "Uri.EscapeUriString". Any suggestions?

+7
source share
1 answer

From AWS documentation :

The name for the key is a sequence of Unicode characters whose UTF-8 encoding has a length of not more than 1024 bytes.

Thus, "ab # 1" and "ab # 2" are valid key names, then the problem is probably in your client code, check the documentation of your Http client.

AWS also warns about using special characters:

You can use any UTF-8 character in the object key name. However, using certain characters in key names can cause problems with some applications and protocols. The following guidelines will help you achieve maximum compatibility with DNS, network-safe characters, XML parsers, and other APIs.

  • Alphanumeric characters: 0-9 , az , AZ
  • Special characters ! , - , _ , * , ' , ( , )

Therefore, either limit the set of available characters in your application to allow only recommended characters, or fix the problem at the client level.

0
source

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


All Articles