Is it possible to send a POST request to a controller and read the HttpContext.Request.Body
stream immediately after sending the POST request (for example if the file is 10GB large)? If I have a form like this:
<form method="post" enctype="multipart/form-data">
and a controller like this:
public class FileController : ControllerBase
{
[HttpPost("[action]")]
public async Task Upload()
{
var stream = HttpContext.Request.Body;
}
}
If I submit a file, it uploads the file first (as I can see in my browser), and then it hits the controller afterwards, with the whole file saved in a temporary file, as you can see here: https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.AspNetCore.WebUtilities/FileBufferingReadStream.cs#L186
I can verify that it saves the uploaded file to disk, which won't work for my application, as I don't have unlimited storage. My end goal is to upload the file to FTP, so the request goes like this:
client -> service -> FTP
What am I doing wrong?