Beispiel #1
0
        /// <summary>
        /// Lists all buckets, optionaly filtering by prefix. Prefix filtering happens on client side.
        /// </summary>
        public async Task <IReadOnlyCollection <Blob> > ListAsync(ListOptions options = null, CancellationToken cancellationToken = default)
        {
            if (options == null)
            {
                options = new ListOptions();
            }

            GenericValidation.CheckBlobPrefix(options.FilePrefix);

            AmazonS3Client client = await GetClientAsync().ConfigureAwait(false);

            IReadOnlyCollection <Blob> blobs;

            using (var browser = new AwsS3DirectoryBrowser(client, _bucketName))
            {
                blobs = await browser.ListAsync(options, cancellationToken).ConfigureAwait(false);
            }

            if (options.IncludeAttributes)
            {
                foreach (IEnumerable <Blob> page in blobs.Where(b => !b.IsFolder).Chunk(ListChunkSize))
                {
                    await Converter.AppendMetadataAsync(client, _bucketName, page, cancellationToken).ConfigureAwait(false);
                }
            }

            return(blobs);
        }
Beispiel #2
0
        private async Task DeleteAsync(string fullPath, AmazonS3Client client, CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPath(fullPath);

            fullPath = StoragePath.Normalize(fullPath, true);

            await client.DeleteObjectAsync(_bucketName, fullPath, cancellationToken).ConfigureAwait(false);

            using (var browser = new AwsS3DirectoryBrowser(client, _bucketName))
            {
                await browser.DeleteRecursiveAsync(fullPath, cancellationToken).ConfigureAwait(false);
            }
        }