public static MediaFile[] GetAssetFiles(StorageBlobClient blobClient, string containerName, string directoryPath, out bool assetStreamable) { assetStreamable = false; List <MediaFile> files = new List <MediaFile>(); CloudBlockBlob[] blobs = blobClient.ListBlobContainer(containerName, directoryPath); foreach (CloudBlockBlob blob in blobs) { string fileName = blob.Name; string fileSize = blobClient.GetBlobSize(containerName, directoryPath, fileName, out long byteCount, out string contentType); MediaFile file = new MediaFile() { Name = fileName, ContentType = contentType, DownloadUrl = blobClient.GetDownloadUrl(containerName, fileName), ByteCount = byteCount, Size = fileSize }; if (file.Name.EndsWith(Constant.Media.Stream.ManifestExtension, StringComparison.OrdinalIgnoreCase)) { assetStreamable = true; } files.Add(file); } return(files.ToArray()); }
internal static MediaFile[] GetAssetFiles(StorageBlobClient blobClient, string containerName, string directoryPath) { BlobContinuationToken continuationToken = null; List <MediaFile> files = new List <MediaFile>(); CloudBlobContainer blobContainer = blobClient.GetBlobContainer(containerName); do { BlobResultSegment blobList; if (!string.IsNullOrEmpty(directoryPath)) { CloudBlobDirectory blobDirectory = blobContainer.GetDirectoryReference(directoryPath); blobList = blobDirectory.ListBlobsSegmentedAsync(continuationToken).Result; } else { blobList = blobContainer.ListBlobsSegmentedAsync(continuationToken).Result; } foreach (IListBlobItem blobItem in blobList.Results) { string fileName = Path.GetFileName(blobItem.Uri.ToString()); string fileSize = blobClient.GetBlobSize(containerName, directoryPath, fileName, out long byteCount, out string contentType); MediaFile file = new MediaFile() { Name = fileName, Size = fileSize, ByteCount = byteCount, ContentType = contentType, DownloadUrl = blobClient.GetDownloadUrl(containerName, fileName, false) }; files.Add(file); } continuationToken = blobList.ContinuationToken; } while (continuationToken != null); return(files.ToArray()); }