【发布时间】:2020-08-31 08:39:56
【问题描述】:
我发现了一堆示例,这些示例使用了我的应用程序中不可用的对象,并且似乎与我的 .NET Core Web API 版本不匹配。从本质上讲,我正在开发一个在网页上有标签的项目,并希望使用来自服务器的流加载视频,而不是直接通过路径提供文件。一个原因是文件的来源可能会改变,并且通过路径提供它们不是我的客户想要的。所以我需要能够打开一个流并异步写入视频文件。
由于某种原因,这会产生 JSON 数据,所以这是错误的。我正在从 Azure Blob 存储下载视频文件并以流的形式返回,但我只是不明白如何将流式视频文件发送到 HTML 中的标签。
我的 API 控制器,
[AllowAnonymous]
[HttpGet("getintroductoryvideos")]
public async Task<Stream> GetIntroductoryVideos()
{
try
{
return _documentsService.WriteContentToStream().Result;
}
catch (Exception ex)
{
throw ex;
}
}
我的服务类,
public async Task<Stream> WriteContentToStream()
{
var cloudBlob = await _blobService.GetBlobAsync(PlatformServiceConstants._blobIntroductoryVideoContainerPath + PlatformServiceConstants.IntroductoryVideo1, introductoryvideocontainerName);
await cloudBlob.FetchAttributesAsync();
var fileStream = new MemoryStream();
await cloudBlob.DownloadToStreamAsync(fileStream);
return fileStream;
}
【问题讨论】:
-
这是什么_blobService?
标签: c# azure html5-video asp.net-core-webapi azure-blob-storage