Exemplo n.º 1
0
        protected async Task CreateTempBucketAsync(Func <string, Task> action)
        {
            string tempBucketName = "testbucket-" + Guid.NewGuid();

            PutBucketResponse putResponse = await BucketClient.PutBucketAsync(tempBucketName, request => request.Region = Config.Region).ConfigureAwait(false);

            Assert.True(putResponse.IsSuccess);

            try
            {
                await(action?.Invoke(tempBucketName)).ConfigureAwait(false);
            }
            catch (Exception)
            {
            }

            DeleteBucketStatus errorCode = await BucketClient.DeleteBucketRecursiveAsync(tempBucketName).ConfigureAwait(false);

            Assert.Equal(DeleteBucketStatus.Ok, errorCode);
        }
Exemplo n.º 2
0
        public static async Task <DeleteBucketStatus> DeleteBucketRecursiveAsync(this IS3BucketClient client, string bucketName, CancellationToken token = default)
        {
            Validator.RequireNotNull(client);
            Validator.RequireNotNull(bucketName);

            DeleteBucketStatus emptyResp = await client.EmptyBucket(bucketName, token).ConfigureAwait(false);

            if (emptyResp != DeleteBucketStatus.Ok)
            {
                return(emptyResp);
            }

            DeleteBucketResponse delResponse = await client.DeleteBucketAsync(bucketName, null, token).ConfigureAwait(false);

            if (!delResponse.IsSuccess && delResponse.Error.Code == ErrorCode.BucketNotEmpty)
            {
                return(DeleteBucketStatus.BucketNotEmpty);
            }

            return(DeleteBucketStatus.Ok);
        }