我有一个rest端点,我似乎无法从一个有效的Azure Blob中导出图片。当我在debug中查看流时,它有适当的字节大小,并且看起来很健康。
下面的代码有效(
为简洁起见,未显示Azure creds/容器的装载
),但在输出返回时失败(见下文500)
if (await blockBlob.ExistsAsync())
{
var stream = new MemoryStream();
await blockBlob.DownloadToStreamAsync(stream);
return new FileStreamResult(stream, "image/jpeg");
后果
500(错误:内部服务器错误):
server: Kestrel
x-sourcefiles: =?UTF-8BQzpcX0NvZGVcUGV0U21hcnRcUG9kc1xQT0RTXGN1c3RvbWVyc1xwaG90b3NcZG93bmxvYWQ=?=
x-powered-by: ASP.NET
date: Fri, 01 Jun 2018 21:21:18 GMT
content-length: 0
终点
[HttpGet]
[Route("/photos/download")]
[SwaggerOperation("Photo Download")]
public async Task<IActionResult> DownloadPhoto([FromQuery]long? photoId)
这个硬编码的返回像一个符咒
var image = System.IO.File.OpenRead(@"C:\Temp\info.png");
return File(image, "image/jpeg");
我可以在Azure Storage Explorer中查看和下载命名的blob。