I am currently trying to receive and work with pdf/image-files in a net 6 web api.
I am testing my attempts through postman, loading a pdf-file into the body as a binary. I believe that, regardless of media type, I should be able to load the binary from the body into a stream and then go from there - but I can't get that to work.
Below are my two attempts of making the Postman-Test return anything that shows me I have successfully accessed the binary and turned it into a format I can work with.
Screenshot of my first approach tested via Postman, asking for a file
[HttpPost]
public async Task<dynamic> CreateDeal([FromForm] IFormFile file)
{
return file.Name;
}
Screenshot of my second approach tested via Postman, telling me the media type is unsupported
[HttpPost]
public async Task<dynamic> CreateDeal([FromBody] Stream file)
{
return file.Length;
}
Any help pointing me in the right direction would be greatly appreciated, would love to find some documentation I can read to clear up my (obvious) misunderstanding of some of the concepts.