Ejemplo n.º 1
0
        private static void FillResult(RavenStorageClient.ListBlobResult result, Page <BlobHierarchyItem> page, bool listFolders)
        {
            result.List = page.Values
                          .Where(x => listFolders || x.IsBlob)
                          .Select(x => listFolders ? RestorePointsBase.GetDirectoryName(x.IsPrefix ? x.Prefix : x.Blob.Name) : x.Blob.Name)
                          .Distinct()
                          .Select(x => new RavenStorageClient.BlobProperties {
                Name = x
            })
                          .ToList();

            if (string.IsNullOrWhiteSpace(page.ContinuationToken) == false)
            {
                result.ContinuationToken = page.ContinuationToken;
            }
        }
Ejemplo n.º 2
0
        public async Task <RavenStorageClient.ListBlobResult> ListBlobsAsync(string prefix, string delimiter, bool listFolders, string continuationToken = null)
        {
            var pageable = _client.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: delimiter, cancellationToken: _cancellationToken);
            var pages    = pageable.AsPages(continuationToken: continuationToken);

            var result = new RavenStorageClient.ListBlobResult();

            await using (var enumerator = pages.GetAsyncEnumerator(cancellationToken: _cancellationToken))
            {
                while (await enumerator.MoveNextAsync())
                {
                    FillResult(result, enumerator.Current, listFolders);
                    break;
                }
            }

            return(result);
        }