public async Task <List <VideoMetaData> > GetAllVideos() { var allFiles = _storageManager.GetAllFilesInContainer(_containerName); if (allFiles.Result == null) { return(new List <VideoMetaData>()); } var resultList = new List <VideoMetaData>(); var currentVideo = new VideoMetaData(); foreach (var listBlobItem in allFiles.Result)//NOTE: Assuming here that a thumbnail will be immediately followed by its corresponding mp4 file { if (listBlobItem.Name.Contains("thumbnail")) { currentVideo = new VideoMetaData(); var thumbnail = new byte[listBlobItem.Properties.Length]; for (var k = 0; k < listBlobItem.Properties.Length; k++) { thumbnail[k] = 0x20; } await listBlobItem.DownloadToByteArrayAsync(thumbnail, 0); currentVideo.Thumbnail = thumbnail; } else { currentVideo.Id = listBlobItem.Name.Replace(".mp4", ""); if (listBlobItem.Properties.LastModified != null) { currentVideo.DateStored = listBlobItem.Properties.LastModified.Value.DateTime; } listBlobItem.Metadata.TryGetValue("duration", out var time); currentVideo.Duration = int.Parse(time ?? Empty); listBlobItem.Metadata.TryGetValue("originalName", out var oldName); currentVideo.Name = oldName; resultList.Add(currentVideo); } } return(resultList); }
public GetPipelinesResponse GetPipelines() { var allFiles = _storageManager.GetAllFilesInContainer(_containerName); if (allFiles.Result == null) { return(new GetPipelinesResponse { Pipelines = new List <Pipeline>() }); } var resultList = new List <Pipeline>(); foreach (var listBlobItem in allFiles.Result) { var currentPipeline = ConvertFileToPipeline(listBlobItem).Result; resultList.Add(currentPipeline); } var response = new GetPipelinesResponse { Pipelines = resultList }; return(response); }