As my review to the
Microsoft.AspNet.Http.Abstractions
the IFormFile is missing the
InputStream and ContentLength
in ASP.NET MVC 6, it insteads of OpenReadStream, which is not functioned to respnse to the ConvertToBytes, for example:
private byte[] ConvertToBytes(IFormFile image)
{
byte[] imageBytes = null;
BinaryReader reader = new BinaryReader(image.InputStream);
imageBytes = reader.ReadBytes((int) image.ContentLength);
return imageBytes;
}
Do you know what happen to
InputStream
and
ContentLength
? In the IFormFile, are available of
OpenReadStream
and
Length
. I don't know how to use it. Do anyone know how to use it. I would like to have similar code as below example:
<pre lang="C#">
private byte[] ConvertToBytes(IFormFile image)
{
byte[] imageBytes = null;
BinaryReader reader = new BinaryReader(image.OpenReadStream());
imageBytes = reader.ReadBytes((int) image.Length);
return imageBytes;
}</pre>
What I have tried:
<pre lang="C#">
private byte[] ConvertToBytes(IFormFile image)
{
byte[] imageBytes = null;
BinaryReader reader = new BinaryReader(image.OpenReadStream());
imageBytes = reader.ReadBytes((int) image.Length);
return imageBytes;
}</pre>