Minio provides RemoveBucket for deleting an empty bucket, but what's the fastest way to delete a non-empty bucket? For example, it would be nice to quickly clean up after integration tests.
You can use mc rm -r --force which basically does RemoveObjects and then RemoveBucket
mc is fine for CLI, but what about from the SDK?
@mcandre you can do listObjects and use the results to remove the objects and finally remove the empty bucket
As @krishnasrinivas said you can get Iterator and remove them one by one or all with deleteObjects method
try {
$iterator = $s3->getIterator('ListObjects', [
'Bucket' => $bucketName
]);
foreach ($iterator as $object) {
$s3->deleteObject([
'Bucket' => $bucketName,
'Key' => $object['Key']
]);
}
} catch (\Exception $e) {
return $this->response->errorBadRequest();
}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
You can use
mc rm -r --forcewhich basically does RemoveObjects and then RemoveBucket