示例#1
0
        public async Task DeleteAsync(S3FolderKey folderKey)
        {
            if (folderKey == null)
            {
                throw new ArgumentNullException(nameof(folderKey));
            }
            var fileKeys = (await _batchRepositoryReader.GetAllKeysAsync(folderKey)).ToList();

            while (fileKeys.Any())
            {
                var requests = CreateRequests(fileKeys, folderKey);

                var tasks = requests.Select(request => AmazonS3.DeleteObjectsAsync(request));
                await tasks.ThrottleAsync(MaxConcurrentTasks);

                //request for keys again, because sometimes some files are still not deleted
                fileKeys = (await _batchRepositoryReader.GetAllKeysAsync(folderKey)).ToList();
            }
        }