title: C# IFormFile wrapper interface
body: <p>I feel like this is a pretty easy thing to do but for some reason in my code I am getting a null value.</p>
  <p>The front-end is Angular and the back-end is C# .NET.</p>
  <p>I am making a post to upload formData. My problem is happening when the form is submitted and I make a POST to upload images to the blob container.</p>
  <p>When a user uploads the photo and they submit the form the photo is converted to a base64 image. And there is one custom attribute added to the imageFile:</p>
  <p>This is the <strong>post data</strong>:</p>
  <pre><code>File{
      isThumbnail: false, 
      name: &quot;Forest-Village.jpg&quot;, 
      lastModified: 1638304459833, 
      size: 205605, 
      type: &quot;image/jpeg&quot;, 
      lastModifiedDate: Tue Nov 30 2021 15:34:19 GMT-0500 (Eastern Standard Time) {}, 
      webkitRelativePath: &quot;&quot;
  }
  </code></pre>
  <p>I want to use <strong>isThumbnail</strong> on the backend. But on the backend, the POST is only works when the type in the parameter is set to <strong>ICollection&lt;IFormFile&gt;</strong></p>
  <pre><code>[HttpPost]
  public async Task&lt;ActionResult&lt;IEnumerable&lt;T&gt;&gt;&gt; UploadPhotos([FromRoute] Guid Id, ICollection&lt;IFormFile&gt; files, CancellationToken cancellationToken = default){}
  
  </code></pre>
  <p>Which will then get the following in the <strong>files parameter</strong> of the post:</p>
  <pre><code>ContentDisposition: form-data; name=&quot;files&quot;; filename=&quot;Forest-Village.jpg&quot;
  ContentType: &quot;image/jpeg&quot;
  FileName: Forest-Village.jpg
  Headers:{Microsoft.AspNetCore.Http.HeaderDictionary}
  Length: 205605
  Name: &quot;files&quot;
  </code></pre>
  <p>So I am missing the <strong>isThumbnail</strong> attribute.</p>
  <p><strong>IFormFile</strong> interface contains these methods and attributes for reference:</p>
  <pre><code>namespace Microsoft.AspNetCore.Http
  {
      // Summary:
      //     Represents a file sent with the HttpRequest.
      public interface IFormFile
      {
          string ContentType { get; }
          string ContentDisposition { get; }
          IHeaderDictionary Headers { get; }
          long Length { get; }
          string Name { get; }
          string FileName { get; }
          void CopyTo(Stream target);
          Task CopyToAsync(Stream target, CancellationToken cancellationToken = default);
          Stream OpenReadStream();
      }
  }
  </code></pre>
  <p>So I created this <strong>IFormFileWrapper</strong> interface and put it in the [httpPost] parameters:</p>
  <pre><code>[HttpPost]
  public async Task&lt;ActionResult&lt;IEnumerable&lt;T&gt;&gt;&gt; UploadPhotos([FromRoute] Guid Id, ICollection&lt;IFormFileWrapper&gt; files, CancellationToken cancellationToken = default){}
  </code></pre>
  <pre><code>public interface IFormFileWrapper : IFormFile
  { 
      bool IsThumbnail { get; }  
  }
  </code></pre>
  <p>But it will give me <strong>null</strong> in the <strong>files parameter</strong> of the post. So it hits the post but none of the attributes are populated.</p>
  <p>So far I have tried:</p>
  <ol>
  <li>Putting nothing in the IFormFileWrapper interface while it inherits IFormFile</li>
  <li>Putting an IFormFile attribute in the IFormFileWrapper interface along with the boolean while inheriting IFormFile</li>
  <li>Making a class called FormFileWrapper which implements all attributes of IFormFileWrapper and IFormFile</li>
  </ol>
  <p>And they all hit the post method but give me null.</p>
  <p>Am I understanding inheritance wrong? Or how it is de-serializing the content from the form?</p>