private int CountContentItemsRecursive(string folderUrl, IBlobStorageProvider blobContentStorageProvider, string excludedFolderUrl = null) { var searchResult = blobContentStorageProvider.SearchAsync(folderUrl, null).GetAwaiter().GetResult(); var retVal = searchResult.TotalCount + searchResult.Results.OfType <BlobFolder>() .Where(x => excludedFolderUrl == null || !x.RelativeUrl.EndsWith(excludedFolderUrl, StringComparison.InvariantCultureIgnoreCase)) .Select(x => CountContentItemsRecursive(x.RelativeUrl, blobContentStorageProvider)) .Sum(); return(retVal); }
private static int CountContentItemsRecursive(string folderUrl, IBlobStorageProvider blobContentStorageProvider, string excludedFolderName = null) { var searchResult = blobContentStorageProvider.SearchAsync(folderUrl, null).GetAwaiter().GetResult(); var folders = searchResult.Results.OfType <BlobFolder>(); var retVal = searchResult.TotalCount - folders.Count() + searchResult.Results.OfType <BlobFolder>() .Where(x => string.IsNullOrEmpty(excludedFolderName) || !x.Name.EqualsInvariant(excludedFolderName)) .Select(x => CountContentItemsRecursive(x.RelativeUrl, blobContentStorageProvider)) .Sum(); return(retVal); }
protected virtual async Task <ICollection <BlobEntry> > ReadBlobFolderAsync(string folderPath, ICancellationToken token) { token?.ThrowIfCancellationRequested(); var result = new List <BlobEntry>(); var searchResults = await _storageProvider.SearchAsync(folderPath, null); result.AddRange(searchResults.Results.Where(item => SupportedImageExtensions.Contains(Path.GetExtension(item.Name).ToLowerInvariant()))); foreach (var blobFolder in searchResults.Results.Where(x => x.Type == "folder")) { var folderResult = await ReadBlobFolderAsync(blobFolder.RelativeUrl, token); result.AddRange(folderResult); } return(result); }
protected virtual async Task <ICollection <BlobEntry> > ReadBlobFolderAsync(string folderPath, ICancellationToken token) { token?.ThrowIfCancellationRequested(); var result = new List <BlobEntry>(); var searchResults = await _storageProvider.SearchAsync(folderPath, null); result.AddRange(searchResults.Results); foreach (var blobFolder in searchResults.Results.Where(x => x.Type == "folder")) { var folderResult = await ReadBlobFolderAsync(blobFolder.RelativeUrl, token); result.AddRange(folderResult); } return(result); }
public async Task<IActionResult> SearchAssetItemsAsync([FromQuery]string folderUrl = null, [FromQuery] string keyword = null) { var result = await _blobProvider.SearchAsync(folderUrl, keyword); return Ok(result); }