✅ httpclient get download stream in blazor

i have this code to download a file from remote source (about 100 MB).
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();
}
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. thanks
3 Replies
Wz
Wz2y ago
GitHub
StreamReader.ReadLineAsync() does not return before its internal bu...
Is there an existing issue for this? I have searched the existing issues Describe the bug That bug report is about a regression between Blazor 6.0.11 and Blazor 7.0.0 Conditions: An API endpoint on...
realivanjxツ
realivanjxツOP2y ago
apparently it seems to be a regression. if there is no more updates i will just use blazore 6 😦 $close
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server