Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 boto - how to delete folder?

I created a folder in s3 named "test" and I pushed "test_1.jpg", "test_2.jpg" into "test".

How can I use boto to delete folder "test"?

like image 865
wade huang Avatar asked Jul 11 '12 06:07

wade huang


People also ask

How do I delete a folder on my S3 boto3?

Your answer You can delete the folder by using a loop to delete all the key inside the folder and then deleting the folder.

How do I delete a folder from my AWS S3?

In the Buckets list, choose the name of the bucket that you want to delete folders from. In the Objects list, select the check box next to the folders and objects that you want to delete. Choose Delete.

How do I delete files from my S3 Boto?

You can delete the file from S3 bucket by using object. delete().

How do I delete files from Amazon S3?

If you no longer need to store the file you've uploaded to your Amazon S3 bucket, you can delete it. Within your S3 bucket, select the file that you want to delete, choose Actions, and then choose Delete. In the confirmation message, choose OK.


1 Answers

Here is 2018 (almost 2019) version:

s3 = boto3.resource('s3') bucket = s3.Bucket('mybucket') bucket.objects.filter(Prefix="myprefix/").delete() 
like image 67
Raz Avatar answered Oct 07 '22 21:10

Raz