Exemple #1
0
        /// <summary>
        /// Create bucket
        /// </summary>
        /// <param name="bucketName">Bucket name - Validation: lower case alpha numeric characters plus dots.</param>
        /// <returns></returns>
        /// <exception cref="BucketNameIsNotValidException">Thrown when bucket name is invalid.</exception>
        /// <exception cref="BucketExistsException">Thrown when bucket already exists with this name.</exception>
        /// <exception cref="EndpointUnreachableException">Thrown when S3 endpoint is unreachable.</exception>
        /// <exception cref="S3BaseException">Thrown when exception is not handled.</exception>
        public async Task CreateBucket(string bucketName)
        {
            try
            {
                Validation.ValidateBucketName(bucketName);

                await _requestRetryPolicy.ExecuteAsync(async() =>
                {
                    var exists = await _bucketOperationsClient.BucketExistsAsync(bucketName.ToLower());

                    if (exists)
                    {
                        throw new BucketExistsException(bucketName);
                    }

                    await _bucketOperationsClient.MakeBucketAsync(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());
            }
        }
Exemple #2
0
        public void MakeBucket()
        {
            var task = minio.MakeBucketAsync(bucketName, region);

            task.Wait();
            logger.Information(string.Format("Bucket {0} successfully created", bucketName));
        }