I want to list only the objects in a bucket that aren’t buckets themselves. Is there a way of doing this short of parsing out the results of ListBucket?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Buckets can’t contain other buckets. Do you mean folders? S3 doesn’t have a concept of folders either.
You can have 100 buckets per S3 account and each bucket can contain an unlimited number of objects/files. If you name your files with
/‘s in the filename, the AWS GUI tools (eg AWS Console, BucketExplorer etc) will interpret each section as a virtual folder. egA file named
folder1/folder2/myfile.jpgwill be stored in S3 as a ‘flat’ file with that name, but in the GUI tools it will appear as though a file namedmyfile.jpgis 2 subfolders down infolder1/folder2.You can use the
prefixanddelimiterparameters to parse the results of a GET Bucket (List Objects) call. The same options are available in any of the SDKs too.UPDATE to answer comment.
Assuming our S3 bucket looks like this:
Using
prefix = "folder1/"would return all 6 files :file1.txttofile6.txt.Using a
prefix = "folder1/"and adelimiter = "/"would return 2 files:And the
CommonPrefixescollection of the response with contain