Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudflare R2 - Delete all objects from bucket

Is there an easy way to delete all objects from a Cloudflare R2 bucket?

This isn't something I'd want to do in production, but something that I want to do while testing in development. I'd love to be able to select more than 25 objects at a time from the dashboard or delete all objects from a CLI.

like image 901
Phil-6 Avatar asked May 07 '26 00:05

Phil-6


1 Answers

Thanks to Juan Fontes' comment above, I tried this out and the following worked.

aws s3 rm s3://<bucket-name> --endpoint-url https://<cloudflare-id>.r2.cloudflarestorage.com --recursive --dryrun

After it's working for you, rerun without the --dryrun flag.

Don't forget to configure the AWS CLI first.

like image 184
Joel Wigton Avatar answered May 09 '26 11:05

Joel Wigton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!