public async Task <IReadOnlyCollection <Filesystem> > ListFilesystemsAsync(CancellationToken cancellationToken) { FilesystemList response = await InvokeAsync <FilesystemList>( "?resource=account", RequestMethod.Get, cancellationToken); return(response.Filesystems); }
public async Task <IReadOnlyCollection <Blob> > ListAsync(ListOptions options = null, CancellationToken cancellationToken = default) { if (options == null) { options = new ListOptions() { FolderPath = "/", Recurse = true }; } GenericValidation.CheckBlobFullPath(options.FolderPath); var info = new PathInformation(options.FolderPath); int maxResults = options.MaxResults ?? ListBatchSize; var blobs = new List <Blob>(); FilesystemList filesystemList = await Client.ListFilesystemsAsync(cancellationToken : cancellationToken); IEnumerable <FilesystemItem> filesystems = filesystemList.Filesystems .Where(x => info.Filesystem == "" || x.Name == info.Filesystem) .OrderBy(x => x.Name); foreach (FilesystemItem filesystem in filesystems) { try { DirectoryList directoryList = await Client.ListDirectoryAsync( filesystem.Name, info.Path, options.Recurse, cancellationToken : cancellationToken); IEnumerable <Blob> results = directoryList.Paths .Where(x => options.FilePrefix == null || x.Name.StartsWith(options.FilePrefix)) .Select(x => new Blob($"{filesystem.Name}/{x.Name}", x.IsDirectory ? BlobItemKind.Folder : BlobItemKind.File)) .Where(x => options.BrowseFilter == null || options.BrowseFilter(x)) .OrderBy(x => x.FullPath); blobs.AddRange(results); } catch (DataLakeGen2Exception e) when(e.StatusCode == HttpStatusCode.NotFound) { } if (blobs.Count >= maxResults) { return(blobs.Take(maxResults).ToList()); } } return(blobs.ToList()); }
private async Task <IReadOnlyCollection <Blob> > ListFilesystemsAsync(ListOptions options, CancellationToken cancellationToken) { //todo: paging FilesystemList filesystems = await _api.ListFilesystemsAsync().ConfigureAwait(false); IEnumerable <Blob> result = filesystems.Filesystems .Select(LConvert.ToBlob); if (options.BrowseFilter != null) { result = result.Where(fs => options.BrowseFilter == null || options.BrowseFilter(fs)); } if (options.MaxResults != null) { result = result.Take(options.MaxResults.Value); } return(result.ToList()); }
public async Task <IEnumerable <string> > ListFilesystemsAsync() { FilesystemList list = await _restApi.ListFilesystemsAsync().ConfigureAwait(false); return(list.Filesystems.Select(x => x.Name)); }