File upload issue in aspnet core

27 Views Asked by At

I'm facing a strange issue with handling file upload in aspnet core using .net6. I'm working with REST api and implemented uploading of binary files. I need just to save binary files from the request to the folder on server. For reading files from request and saving them I use the code like that:

await Request.Body.CopyToAsync(stream,...)

The problem it that when I'm checking Request.Body it contains more bytes than original file. When saving contents of Request.Body to the file, the created file contains a lot of additional "ef bf bd" bytes so the original file is broken. How these "ef bf bd" bytes arrive in the request body?

0

There are 0 best solutions below