From the AWS docs, I understand that:
However, these rules seem too permissive.
For instance, if I make a key called '../../d', a 400 ERROR occurs when I attempt to access it with the GET OBJECT API. Interestingly, I have no problem accessing '../d'.
Is there a document specifying what is and is not legal?
The object key (or key name) uniquely identifies the object in an Amazon S3 bucket. Object metadata is a set of name-value pairs. For more information about object metadata, see Working with object metadata. When you create an object, you specify the key name, which uniquely identifies the object in the bucket.
Bucket names can only contain lowercase letters, numeric characters, dashes ( - ), underscores ( _ ), and dots ( . ). Spaces are not allowed. Names containing dots require verification.
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the bucket that you want to enable an S3 Bucket Key for. Choose Properties. In the Default encryption section, under Bucket Key, you see the S3 Bucket Key setting for your bucket.
According to AWS S3 documentation:
Although you can use any UTF-8 characters in an object key name, the following key naming best practices help ensure maximum compatibility with other applications. Each application may parse special characters differently. The following guidelines help you maximize compliance with DNS, web safe characters, XML parsers, and other APIs.
Please find below the
The following character sets are generally safe for use in key names:
NOTE ABOUT THE DELIMITER ("/")
The following are examples of valid object key names:
4my-organization
my.great_photos-2014/jan/myvacation.jpg
videos/2014/birthday/video1.wmv
Note that the Amazon S3 data model is a flat structure: you create a bucket, and the bucket stores objects. There is no hierarchy of subbuckets or subfolders; however, you can infer logical hierarchy using keyname prefixes and delimiters as the Amazon S3 console does.
e.g if you use Private/taxdocument.pdf as a key, it will create the Private folder, with taxdocument.pdf in it.
Amazon S3 supports buckets and objects, there is no hierarchy in Amazon S3. However, the prefixes and delimiters in an object key name, enables the Amazon S3 console and the AWS SDKs to infer hierarchy and introduce concept of folders.
The following characters in a key name may require additional code handling and will likely need to be URL encoded or referenced as HEX. Some of these are non-printable characters and your browser may not handle them, which will also require special handling:
You should avoid the following characters in a key name because of significant special handling for consistency across all applications.
The only restrictions provided by Amazon is (as found on their Technical FAQ):
What characters are allowed in a bucket or object name?
A key is a sequence of Unicode characters whose UTF-8 encoding is at most 1024 bytes long.
Additional restrictions apply for Buckets (as found on the Rules for Bucket Naming section of their Bucket Restrictions and Limitations FAQ):
In all regions except for the US Standard region a bucket name must comply with the following rules. These result in a DNS compliant bucket name.
- Bucket names must be at least 3 and no more than 63 characters long
- Bucket name must be a series of one or more labels separated by a period (.), where each label:
- Must start with a lowercase letter or a number
- Must end with a lowercase letter or a number
- Can contain lowercase letters, numbers and dashes
- Bucket names must not be formatted as an IP address (e.g., 192.168.5.4)
Less permissive restrictions apply to the US standard region. Please see the FAQs for additional information and some examples. Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With