Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty folders in AWS S3

I (think I) understood the concept of S3 of being a key based storage, where the key is actually the path to the file. Thus there is no concept of folders. But how come, that it is possible to create empty folders in S3? Also, my impression is, that the empty folders exist only for a short period of time (a couple of hours) and then disappear automatically.

like image 243
Roland Ettinger Avatar asked Jul 20 '17 06:07

Roland Ettinger


1 Answers

When a folder is created in the Amazon S3 Management Console, it actually creates a zero-length object with the name of the folder. This causes it to appear in the console.

If the object is deleted and there are no files using that path, then the folder will also disappear:

$ aws s3 ls s3://my-bucket
                           PRE foo/

$ aws s3 ls s3://my-bucket/foo/
2017-07-20 07:09:20          0 

$ aws s3 rm s3://my-bucket/foo/
delete: s3://my-bucket/foo/

$ aws s3 ls s3://my-bucket
$
like image 89
John Rotenstein Avatar answered Oct 19 '22 07:10

John Rotenstein