Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 - ListObjects returns incomplete directory listings

I use ListObject function without any delimiters and as result I have something that look like:

/BF
/BF/FTP
/BF/MUSIC/LIBRARY/AUDITION/BEAKING%20EARLY.MP3
/BF/VIDEO/
/BF/VIDEO/Example
/BF/VIDEO/Example/test.mp4

The problem is in the music folder. Why ListObjects doesn't return S3Object with key: "/BF/MUSIC". There are many S3Objects with the same problem. Why is that happening?

like image 928
kkost Avatar asked Dec 29 '25 01:12

kkost


1 Answers

The reason is S3 actually has a flat structure. There are no folders but it just recognizes the forward slashes so groups the ones having the same prefix under same folder. So in your example "/BF/MUSIC" would be just another object, not an empty folder.

In Amazon S3, buckets and objects are the primary resources, where objects are stored in buckets. Amazon S3 has a flat structure with no hierarchy like you would see in a typical file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. Amazon S3 does this by using key name prefixes for objects.

Source: AWS Documentation: Working with Folders

like image 129
Volkan Paksoy Avatar answered Dec 31 '25 17:12

Volkan Paksoy