예제 #1
0
파일: Program.cs 프로젝트: Genbox/SimpleS3
    private static async IAsyncEnumerable <S3Bucket> ListAllBucketsAsync(IBucketClient client)
    {
        ListBucketsResponse response = await client.ListBucketsAsync().ConfigureAwait(false);

        foreach (S3Bucket bucket in response.Buckets)
        {
            yield return(bucket);
        }
    }
        /// <summary>List all buckets</summary>
        public static async IAsyncEnumerable <S3Bucket> ListAllBucketsAsync(this IBucketClient client, Action <ListBucketsRequest>?config = null, [EnumeratorCancellation] CancellationToken token = default)
        {
            ListBucketsResponse response = await client.ListBucketsAsync(config, token).ConfigureAwait(false);

            if (!response.IsSuccess)
            {
                throw new S3RequestException(response.StatusCode, "Request failed");
            }

            if (token.IsCancellationRequested)
            {
                yield break;
            }

            foreach (S3Bucket bucket in response.Buckets)
            {
                if (token.IsCancellationRequested)
                {
                    yield break;
                }

                yield return(bucket);
            }
        }
예제 #3
0
 public Task <ListBucketsResponse> ListBucketsAsync(Action <ListBucketsRequest>?config = null, CancellationToken token = default)
 {
     return(_bucketClient.ListBucketsAsync(config, token));
 }