How can I get only one level of objects in a S3 bucket?
-
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?
-
Answer:
objects in a bucket that aren't buckets themselves 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. eg A file named folder1/folder2/myfile.jpg will be stored in S3 as a 'flat' file with that name, but in the GUI tools it will appear as though a file named myfile.jpg is 2 subfolders down in folder1/folder2. You can use the prefix and delimiter parameters to parse the results of a http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?RESTBucketGET.html call. The same options are available in any of the SDKs too. UPDATE to answer comment. Assuming our S3 bucket looks like this: mybucket folder1 file1.txt file2.txt folder2 file3.txt file4.txt folder3 file5.txt file6.txt Using prefix = "folder1/" would return all 6 files : file1.txt to file6.txt. Using a prefix = "folder1/" and a delimiter = "/" would return 2 files: file1.txt file2.txt And the CommonPrefixes collection of the response with contain folder1/folder2/ folder1/folder3/
Graham Chiu at Stack Overflow Visit the source
Related Q & A:
- How can I get an audio alert when I get a new e-mail?Best solution by Yahoo! Answers
- How can I get my regular avatar of a real picture back as my avatar instead of the one now?Best solution by Yahoo! Answers
- How can i send some one a text through my computer?Best solution by Yahoo! Answers
- How can I get a text alert when I get an email?Best solution by Yahoo! Answers
- How can I get a job at a resort for a Summer?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.