コード例 #1
0
        public static Task <DeleteMultipleObjectsResponse> DeleteMultipleObjectsAsync(this IS3ObjectClient client, string bucketName, IEnumerable <S3DeleteInfo> resources, MfaAuthenticationBuilder mfa = null, CancellationToken token = default)
        {
            Validator.RequireNotNull(client);
            Validator.RequireNotNull(bucketName);
            Validator.RequireNotNull(resources);

            return(client.DeleteMultipleObjectsAsync(bucketName, resources, req => req.Mfa = mfa, token));
        }
コード例 #2
0
        public static Task <DeleteMultipleObjectsResponse> DeleteMultipleObjectsAsync(this IS3ObjectClient client, string bucketName, IEnumerable <string> resources, Action <DeleteMultipleObjectsRequest> config = null, CancellationToken token = default)
        {
            Validator.RequireNotNull(client);
            Validator.RequireNotNull(bucketName);
            Validator.RequireNotNull(resources);

            return(client.DeleteMultipleObjectsAsync(bucketName, resources.Select(x => new S3DeleteInfo(x, null)), config, token));
        }
コード例 #3
0
ファイル: S3BucketClient.cs プロジェクト: LordMike/SimpleS3
        public async Task <DeleteBucketStatus> EmptyBucket(string bucketName, CancellationToken token = default)
        {
            //TODO: this can be optimized if we don't use GetBucketRecursiveAsync, but instead call the methods directly
            List <S3DeleteInfo> tempList = new List <S3DeleteInfo>(1000);

            await foreach (S3Object obj in this.GetBucketRecursiveAsync(bucketName, token: token))
            {
                tempList.Add(new S3DeleteInfo(obj.Name, null));

                if (tempList.Count != 1000)
                {
                    continue;
                }

                DeleteMultipleObjectsResponse multiDelResponse = await _objectClient.DeleteMultipleObjectsAsync(bucketName, tempList, request => request.Quiet = true, token).ConfigureAwait(false);

                if (!multiDelResponse.IsSuccess)
                {
                    return(DeleteBucketStatus.FailedToDeleteObject);
                }

                tempList.Clear();
            }

            if (tempList.Count > 0)
            {
                DeleteMultipleObjectsResponse multiDelResponse = await _objectClient.DeleteMultipleObjectsAsync(bucketName, tempList, request => request.Quiet = true, token).ConfigureAwait(false);

                if (!multiDelResponse.IsSuccess)
                {
                    return(DeleteBucketStatus.FailedToDeleteObject);
                }
            }

            return(DeleteBucketStatus.Ok);
        }
コード例 #4
0
ファイル: S3Client.cs プロジェクト: LordMike/SimpleS3
 public Task <DeleteMultipleObjectsResponse> DeleteMultipleObjectsAsync(string bucketName, IEnumerable <S3DeleteInfo> resources, Action <DeleteMultipleObjectsRequest> config = null, CancellationToken token = default)
 {
     return(_objectClient.DeleteMultipleObjectsAsync(bucketName, resources, config, token));
 }