1

I'm trying to perform a large video upload to a server, but no matter what I do, if I'm using Httpclient.SendAsync(HttpResponseMessage) to send the content I have assigned to the HttpResponseMessage among with all the headers and such, the whole content will be loaded into the memory.

But I'm using HttpClient.PostAsync(uri, HttpResponseMessage.Content), it'll do the upload normally, without loading the content into the stream.

Is there any workaround, rather than just switch to PostAsync? It doesn't offer me the possibilities SendAsync offers, so I'd rather not do.

Example:

{
    var multiForm = new MultipartFormDataContent(UploadId);
    var fileStream = File.OpenRead(videoPath);
    var streamContent = new StreamContent(fileStream);
    multiForm.Add(streamContent, "video", Path.GetFileName(fs.Name));

    var request = GetHttpReqeustMessage[Method.Post, uri];
    request.Content = multiForm;

    var result = client.SendAsync(request);
}
4

1 回答 1

1

I'm so dumb. I forgot I was tracking the logs for every httprequestmessage, so I'd print everything within a request, including the bytes of the whole video. I want to fly, far away.

于 2019-10-16T17:19:38.797 回答