The following code reads the whole given Stream's data into memory before sending it as a web request rather than reading and sending the data in smaller blocks. For example, if the stream yields 2 GB of data, the code will read all the 2 GB of data into a memory buffer before it starts sending the request. The 50 KB buffer size passed to StreamContent's constructor seem to be ignored.
using (var httpClient = new HttpClient())
{
using (var content = new StreamContent(stream, 1024*50)) // 50 KB buffer size ignored?
{
using (var request = new HttpRequestMessage(HttpMethod.Post, requestUri))
{
request.Content = content;
await httpClient.SendAsync(request);
}
}
}