Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special characters in Amazon S3 file name

Tags:

amazon-s3

Users are uploading files with names like "abc #1", "abc #2". I am uploading these files to S3. When I try to download these files I get an error like this InvalidArgument Header value contained an open quoted span.

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

like image 973
Mithil Avatar asked Apr 11 '12 14:04

Mithil


1 Answers

From AWS documentation:

The name for a key is a sequence of Unicode characters whose UTF-8 encoding is at most 1024 bytes long.

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

AWS also warn about using special characters:

You can use any UTF-8 character in an object key name. However, using certain characters in key names may cause problems with some applications and protocols. The following guidelines help you maximize compliance with DNS, web-safe characters, XML parsers, and other APIs.

  • Alphanumeric characters: 0-9, a-z, A-Z
  • Special characters: !, -, _, ., *, ', (, )

So either restrict the set of available characters in your app to only allow the recommended ones, or fix the issue at your client level.

like image 195
Anthony Garcia-Labiad Avatar answered Oct 26 '22 10:10

Anthony Garcia-Labiad