✅ 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ツ2y 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
More Posts
❔ ILogger is never enabledAny idea what's going on here? https://github.com/dotnet/runtime/issues/80336 ``` using Microsoft.❔ is it possible to make cursor smooth caret animation in a textbox in vs?I just wanted to know because I'm making a web browser and I saw cursor smooth caret animation and I❔ Hi i need wpf helpim following this article https://wpf-tutorial.com/xaml/events-in-xaml/ and i want to know why doesn❔ Is a generic with a where clause equivalent to passing the same type through as a parameterIs there any difference between the following 2 methods? public void DoSomething<T>(T value) where ❔ Only one compilation unit can have top level statements err simple explanationwhen I create another cs file in the same folder I get this error, I just want to know how can I mak✅ 3 objects inheritance thing + force call base.DoThing();So I want to make Class3 inheriting Class2 inheriting abstract Class1, to have Class1's function. Ve❔ How do i assign or change Z order of a button? (Dock buttons)I'm trying to make a list of buttons appear, and dock them top down to a grid in C#. As with most t❔ .NET Framework reference vs NuGet?Hello! In a .NET-framework project I'm working in there are references to .NET assemblies both as re❔ Razor page with multiple forms causes modelstate to be invalid because some properties are nullAnd if I set these properties to nullable, it can't even be overriden with fluent validation .NotNulCannot access non-static method in static context?I'm creating a JSON saving system for my unity game right now. I've already made one before that wor