【发布时间】:2019-11-15 14:59:49
【问题描述】:
我收到IFormFile,我想将其转换为byte[],我的代码如下所示:
private ProductDto GenerateData(Request product, IFormFile file)
{
if (file != null)
{
using (var item = new MemoryStream())
{
file.CopyTo(item);
item.ToArray();
}
}
return new ProductDto
{
product_resp = JsonConvert.SerializeObject(product).ToString(),
file_data = item; // I need here byte []
};
}
我已经尝试了一些方法,但我什至不确定我是否可以按照我尝试的方式将 IFormFile 转换为 byte[],不确定这是否是正确的方法。
无论如何,感谢您的帮助。
【问题讨论】:
-
嗨@Roxy'Pro 你解决问题了吗?
标签: c# .net-core multipartform-data iformfile