C
Join ServerC#
help
✅ httpclient get download stream in blazor
XWYBxianzai wo you bingqiling1/8/2023
i have this code to download a file from remote source (about 100 MB).
but it seems that that code above downloads the whole file first at line
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, REMOTE_URL);
HttpResponseMessage responseMessage = await Http.SendAsync(
requestMessage,
HttpCompletionOption.ResponseHeadersRead);
using Stream remoteStream = await responseMessage.Content.ReadAsStreamAsync();
byte[] buffer = new byte[1024 * 1024];
while (CurrentProgress < MaxProgress)
{
int read = await remoteStream.ReadAsync(
buffer,
0,
buffer.Length);
CurrentProgress += read;
StateHasChanged();
}
but it seems that that code above downloads the whole file first at line
using Stream remoteStream
so i cant really show any progress to the gui. is this a bug with the blazor's httpclient implementation because the code works fine on my wpf app. thanksWWz1/8/2023
You’re probably hitting https://github.com/dotnet/runtime/issues/79238
XWYBxianzai wo you bingqiling1/9/2023
apparently it seems to be a regression. if there is no more updates i will just use blazore 6 😦
XWYBxianzai wo you bingqiling1/9/2023
$close
MMODiX1/9/2023
Use the
/close
command to mark a forum thread as answered