-
Notifications
You must be signed in to change notification settings - Fork 127
S3 Prefixes and Delimiters Explained
timkay edited this page Jan 7, 2013
·
1 revision
S3 does not know about subfolders (subdirectories). A slash is just a slash. There is only one level of folders, called buckets. Inside buckets, there are files, called objects or keys. Thus, by default, if you list the contents of a bucket, you see all the objects:
$ aws ls -1 test682
hello.txt
x/y/hello.txt
S3 has always supported a prefix, which filters the list. Only keys with a matching prefix are displayed:
$ aws ls -1 test682/x
x/y/hello.txt
Later, S3 added a delimiter, which tells S3 to behave as though it has subdirectories. You tell "aws" to use a delimiter with --delimiter=X or -d. If you specify -d, then the delimiter is set to slash (/). This way, you can get behavior similar to what you get under Linux (etc.):
$ aws ls -1d test682/x/
y/
$ aws ls -1d test682/x/y/
hello.txt
The delimiter does not have to be slash, though the results are a bit disturbing:
$ aws ls -1 --delimiter=x test682
hello.tx
x
$ aws ls -1 --delimiter=x test682/hello.tx
t
$ aws ls -1 --delimiter=x test682/x
/y/hello.tx