title: How to parse byte[] array from model with IFormFile from viewmodel for file uploading controller?
body: <p>I have Core MVC application, when for specific entity I have following model:</p>
  
  <pre><code>public class Aktualnosci
      {
          public long ID { get; set; }
          public string Tytul { get; set; }
          public string Tresc { get; set; }
          public DateTime Dzien { get; set; }
          public byte[] AktualnosciImage { get; set; }
      }
  </code></pre>
  
  <p>For uploading the image I am using <code>IFormFile</code> property in my viewmodel, that is called by controller, according to the documentation from <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-2.1" rel="nofollow noreferrer">>>HERE&lt;&lt;</a>:</p>
  
  <pre><code>public class AktualnosciCreateVM
      {
          public long ID { get; set; }
          [Required(ErrorMessage = "Proszę wypełnić pole.")]
          [StringLength(40, ErrorMessage = "Max 40 znaków.")]
          public string Tytul { get; set; }
          [Required(ErrorMessage = "Proszę wypełnić pole.")]
          public string Tresc { get; set; }
          [Required(ErrorMessage = "Proszę wypełnić pole.")]
          public DateTime Dzien { get; set; }
          public IFormFile AktualnosciImage { set; get; }
      }
  </code></pre>
  
  <p>And it is used for creating and editing of the entity. Right now I have troubles with parsing <code>public IFormFile AktualnosciImage { set; get; }</code> and <code>public byte[] AktualnosciImage { get; set; }</code> in my controller's <code>GET</code> method, to have returned viewmodel:</p>
  
  <pre><code>[Authorize(Roles = "Moderatorzy")]
          // GET: Aktualnosci/Edit/5
          public IActionResult Edit(long? id)
          {
              if (id == null)
              {
                  return NotFound();
              }
              Aktualnosci aktualnosci = aktualnosciRepository.AktualnosciList
                  .FirstOrDefault(m =&gt; m.ID == id);
              if (aktualnosci == null)
              {
                  return NotFound();
              }
              else
              {
                  aktualnosciCreateVM.ID = aktualnosci.ID;
                  aktualnosciCreateVM.Tytul = aktualnosci.Tytul;
                  aktualnosciCreateVM.Tresc = aktualnosci.Tresc;
                  aktualnosciCreateVM.Dzien = aktualnosci.Dzien;
  //this one gives me an error v
                  aktualnosciCreateVM.AktualnosciImage = aktualnosci.AktualnosciImage.ToArray();
                  return View(aktualnosciCreateVM);
  
              }
          }
  </code></pre>
  
  <p>The compilation error is:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'byte[]' to
    'Microsoft.AspNetCore.Http.IFormFile'</p>
  </blockquote>
  
  <p>Is there any way to parse this 2 properties?</p>