I receive IFormFile
and I would like to convert it to byte[]
, my code looks like this:
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 []
};
}
I've tried something but I'm not even sure if I can convert IFormFile
to byte[]
on way I tried, not sure if it's right approach.
Anyway, thanks for any help.