/// <summary>List all objects in a bucket</summary> /// <param name="client">The BucketClient</param> /// <param name="bucketName">The name of the bucket you want to list objects in.</param> /// <param name="getOwnerInfo">Set to true if you want to get object owner information as well.</param> /// <param name="token">A cancellation token</param> public static async IAsyncEnumerable <S3Object> GetBucketRecursiveAsync(this IS3BucketClient client, string bucketName, bool getOwnerInfo = false, [EnumeratorCancellation] CancellationToken token = default) { Validator.RequireNotNull(client); Validator.RequireNotNull(bucketName); string continuationToken = null; GetBucketResponse response; do { if (token.IsCancellationRequested) { break; } string cToken = continuationToken; response = await client.GetBucketAsync(bucketName, req => { req.ContinuationToken = cToken; if (getOwnerInfo) { req.FetchOwner = true; } }, token).ConfigureAwait(false); if (!response.IsSuccess) { throw new Exception(); } foreach (S3Object responseObject in response.Objects) { yield return(responseObject); } continuationToken = response.NextContinuationToken; } while (response.IsTruncated); }
public Task <GetBucketResponse> GetBucketAsync(string bucketName, Action <GetBucketRequest> config = null, CancellationToken token = default) { return(_bucketClient.GetBucketAsync(bucketName, config, token)); }