我正在尝试将 base64String 列表转换为 IFormFile 列表。当我尝试时,MemoryStream stream = new MemoryStream(bytes)
我得到了一个stream.ReadTimeout SystemInvalidOperation
. 那么为什么它不起作用?
这是我的代码:
private async Task<List<IFormFile>> Base64ToImage(List<EquipmentFile> equipmentFiles)
{
List<IFormFile> formFiles = new List<IFormFile>();
foreach (var eqp in equipmentFiles)
{
byte[] bytes = Convert.FromBase64String(eqp.File);
MemoryStream stream = new MemoryStream(bytes);
IFormFile file = new FormFile(stream, 0, bytes.Length, eqp.Name, eqp.Name);
formFiles.Add(file);
}
return formFiles;
}
我的堆栈跟踪:
System.InvalidOperationException: Timeouts are not supported on this stream.
at System.IO.Stream.get_ReadTimeout()
at FieldService.CallCenter.Api.Controllers.EquipmentLibraryController.Base64ToImage(List`1 equipmentFiles) in C:\Users\CMTech-DEV\Documents\cmtech\fieldservice-api\src\CallCenter\FieldService.CallCenter.API\Controllers\EquipmentLibraryController.cs:line 331
at System.IO.Stream.get_ReadTimeout()
at FieldService.CallCenter.Api.Controllers.EquipmentLibraryController.Base64ToImage(List`1 equipmentFiles) in C:\Users\CMTech-DEV\Documents\cmtech\fieldservice-api\src\CallCenter\FieldService.CallCenter.API\Controllers\EquipmentLibraryController.cs:line 331