I have the following hierarchy in my s3 bucket
bucket_name/folder1/folder2/file1
bucket_name/folder1/folder2/file1
I am able to delete all the files within folder2, but that leaves the bucket with empty folders as folder1/folder2.
What is the appropriate way of deleting those folders?
Here is what I do to delete a particular file:
Where s3
is my Amazon s3 instance:
s3.buckets[my_bucket_name].objects[path].delete
Ideally I would like to delete the folders an all the contents.
You can use aws-cli to delete a folder :
aws s3 rm s3://mybucket/ --recursive
In order to check what the delete operation will delete, you can set 'dryrun' flag :
aws s3 rm s3://mybucket/ --recursive --dryrun
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With