I am trying to upload a file using Flurl using AddFile
.
The resulting IFormFileCollection
is null, although I am able to see the item when looking at Request.Form.Files[0]
with the right content length.
Creating the request:
public Task<HttpResponseMessage> UploadImage(string fileName, MemoryStream stream)
{
stream.Position = 0;
_baseUrl
.AppendPathSegments("uploadImage")
.PostMultipartAsync(mp => mp
.AddFile("files", stream, fileName))
}
Handling the request:
[HttpPost]
[Route("uploadImage")]
public async Task<HttpResponseMessage> UploadImages([FromForm] IFormFileCollection files)
{
//files is null, but Request.Form.Files[0] in the immediate window shows the file.
}
A common problem seems to be a mismatch in the name of the parameter and the name in the Content-Disposition header, but I updated them to both be files
and I am still having the same issue.