I am trying to send a .png
image from the client to a .NET Core API. I am following the official .NET Core documentation exactly in the API, so my controller endpoint looks like this:
[HttpPut]
public async Task<IActionResult> SaveFile(List<IFormFile> files) {...}
Since I am using Axios, I am using the following example for the front end code:
axios.put(url, imageFile, {
headers: {
'Content-Type': imageFile.type
}
});
I have also tried wrapping the image file into the FormData
class like so:
const formData = new FormData(driversLicenseFile);
axios.put(url, formData , {...
What am I doing wrong? How do I avoid the 415 response code?
The request, the way it appears in the browser is included below, in case that helps you spot any obvious issues.