InputStream and ContentLength is missing in microsoft.aspnet.http.abstractions
<p>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:</p>

<pre><code>private byte[] ConvertToBytes(IFormFile image)
    {
        byte[] imageBytes = null;
        //Then, Read stream in Binary
        BinaryReader reader = new BinaryReader(image.InputStream);
        imageBytes = reader.ReadBytes((int) image.ContentLength);
        return imageBytes;

    }
</code></pre>

<p>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:</p>

<pre><code>private byte[] ConvertToBytes(IFormFile image)
    {
        byte[] imageBytes = null;
        //Then, Read stream in Binary
        BinaryReader reader = new BinaryReader(image.OpenReadStream());
        imageBytes = reader.ReadBytes((int) image.Length);
        return imageBytes;

    }
</code></pre>

<p>What I have tried below code, but it does't work because of BinaryReader reader = new BinaryReader(image.OpenReadStream()) show up System.NullReferenceException was unhandled by user code with HResult=-2147467261
and the Message=Object reference not set to an instance of an object.:</p>

<pre><code>private byte[] ConvertToBytes(IFormFile image)
    {
        byte[] imageBytes = null;
        //Then, Read stream in Binary
        BinaryReader reader = new BinaryReader(image.OpenReadStream());
        imageBytes = reader.ReadBytes((int) image.Length);
        return imageBytes;

    }
</code></pre>

<p>Can you help me to resolve this problem?</p>

<p>I call ConvertToBytes in order to add the image file the database field in varbinary datatype, please see code below:</p>

<pre><code>private readonly ApplicationDbContext db = new ApplicationDbContext();
    public int UploadImageInDataBase(IFormFile file, PublisherInfosViewModel publisherInfosViewModel)
    {
        publisherInfosViewModel.Image = ConvertToBytes(file);
        var publisherInfos = new PublisherInfos
        {
            PubInfoId = publisherInfosViewModel.PubInfoId,
            PubId = publisherInfosViewModel.PubId,
            Title = publisherInfosViewModel.Title,
            Image = publisherInfosViewModel.Image,
            Description = publisherInfosViewModel.Description,
            Contents = publisherInfosViewModel.Contents

        };
        db.PublisherInfos.Add(publisherInfos);
        int i = db.SaveChanges();
        if (i == 1)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
</code></pre>