18

I recently found out that you can fake directory structure on S3 by putting slashes in your filenames. That got me thinking: are there any restrictions at all on object IDs? I'm sure there must be some. Length? Null characters (\0)? Arcane stuff like invalid UTF-8 characters?

I'm sure there must be some restrictions, but I can't seem to find them anywhere in the documentation.

p-static
  • 529
  • 1
  • 4
  • 9
  • 2
    Good question; naming rules for *buckets* seem to be readily available (in Getting Started Guide and User Guide) but not those for objects. – Jonik Jun 30 '10 at 04:25
  • 3
    This was asked 4 years ago, and is still the top google result, wtf amazon? – Adrian Seeley Sep 20 '14 at 10:31

1 Answers1

21

Per the technical documentation:

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

Buckets names have additional restrictions:

We recommend that all bucket names comply with DNS naming conventions.

The rules for DNS-compliant bucket names are:

  • Bucket names must be at least 3 and no more than 63 characters long.
  • Bucket names must be a series of one or more labels. Adjacent labels are separated by a single period (.). Bucket names can contain lowercase letters, numbers, and hyphens. Each label must start and end with a lowercase letter or a number.
  • Bucket names must not be formatted as an IP address (e.g., 192.168.5.4).

At this moment DNS compliant names are not enforced in the US Standard region but Amazon is moving towards that.

Community
  • 1
  • 1
Zachary Ozer
  • 3,019
  • 2
  • 18
  • 15
  • I also suggest avoiding characters that are not compliant for xml1.0. This causes various bugs with boto and probably other implementations. See https://github.com/boto/boto/issues/1459 – omribahumi Sep 20 '15 at 10:45