Minio: How to quickly delete a non-empty bucket?

Created on 24 Jan 2017  路  5Comments  路  Source: minio/minio

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.

community

Most helpful comment

You can use mc rm -r --force which basically does RemoveObjects and then RemoveBucket

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings