/// <summary> /// Remove the bucket with the given name. /// </summary> /// <param name="args">RemoveBucketArgs Arguments Object which has bucket identifier information like bucket name .etc.</param> /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param> /// <returns> Task </returns> /// <exception cref="InvalidBucketNameException">When bucketName is invalid</exception> public async Task RemoveBucketAsync(RemoveBucketArgs args, CancellationToken cancellationToken = default(CancellationToken)) { args.Validate(); RestRequest request = await this.CreateRequest(Method.DELETE, args.BucketName).ConfigureAwait(false); await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken); }
public async Task RemoveBucketAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken)) { RemoveBucketArgs args = new RemoveBucketArgs() .WithBucket(bucketName); await RemoveBucketAsync(args, cancellationToken); }
static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; /// Note: s3 AccessKey and SecretKey needs to be added in App.config file /// See instructions in README.md on running examples for more information. var minio = new MinioClient() .WithEndpoint("play.min.io") .WithCredentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG") .WithSSL() .Build(); var getListBucketsTask = minio.ListBucketsAsync(); try { Task.WaitAll(getListBucketsTask); // block while the task completes } catch (AggregateException aggEx) { aggEx.Handle(HandleBatchExceptions); } var list = getListBucketsTask.Result; foreach (Bucket bucket in list.Buckets) { Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime); } //Supply a new bucket name string bucketName = "mynewbucket"; if (isBucketExists(minio, bucketName)) { RemoveBucketArgs remBuckArgs = new Minio.RemoveBucketArgs() .WithBucket(bucketName); var removeBucketTask = minio.RemoveBucketAsync(remBuckArgs); Task.WaitAll(removeBucketTask); } MakeBucketArgs mkBktArgs = new MakeBucketArgs() .WithBucket(bucketName); Task.WaitAll(minio.MakeBucketAsync(mkBktArgs)); bool found = isBucketExists(minio, bucketName); Console.WriteLine("Bucket exists? = " + found); Console.ReadLine(); }