/// <summary> /// Remove bucket /// </summary> /// <param name="bucketName"></param> /// <returns></returns> /// <exception cref="BucketNotFoundException">Thrown when bucket does not exist.</exception> /// <exception cref="EndpointUnreachableException">Thrown when S3 endpoint is unreachable.</exception> /// <exception cref="S3BaseException">Thrown when exception is not handled.</exception> public async Task RemoveBucket(string bucketName) { try { await _requestRetryPolicy.ExecuteAsync(async() => { var exists = await _bucketOperationsClient.BucketExistsAsync(bucketName.ToLower()); if (!exists) { throw new Exceptions.BucketNotFoundException(bucketName); } await _bucketOperationsClient.RemoveBucketAsync(bucketName.ToLower()); }); } catch (MinioException ex) when(ex is ConnectionException || ex is InternalServerException || ex is InternalClientException || ex is InvalidEndpointException ) { throw new EndpointUnreachableException(_endpoint, ex.ToString()); } catch (S3BaseException) { throw; } catch (Exception ex) { throw new S3BaseException(ex.Message, ex.ToString()); } }
public void RemoveBucket() { var task = minio.RemoveBucketAsync(bucketName); task.Wait(); logger.Information(string.Format("Bucket {0} is removed successfully", bucketName)); }