-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Blazor] HttpPost with StreamContent reads whole file into memory #43388
Comments
Related: dotnet/runtime#36634 |
@mrpmorris thanks for contacting us. Unfortunately, |
Fetch sucks 😢. I've been lobbying the w3c to add this for ages (for different reasons). |
Is there a good reason to use fetch instead of |
@mrpmorris you can't stream the request with XMLHttpRequest either. It's not a problem with the API but a missing capability in the browser. |
@javiercn XMLHttpRequest does stream it. I just uploaded a 1GB file without the memory usage going through the roof. https://twitter.com/MrPeterLMorris/status/1561650669584621568?s=20&t=svki19salJp9qnOvc_So9A |
Is there an existing issue for this?
Describe the bug
When using StreamContent with HttpClient.PostAsync in Blazor WASM, the whole file is loaded into memory before initiating the HTTP call
Expected Behavior
The HTTP call should be made immediately, and the data in the stream should be read in chunks.
Steps To Reproduce
1: Create a hosted Blazor WASM app
2: Add the following to WeatherForecast controller
Now try running the following code in both a console app with FileStream as the source for StreamContent, and then inside a Blazor WASM app with IBrowserFile.Open.OpenReadStream as the source
Results
Console app
Blazor WASM
Exceptions (if any)
No response
.NET Version
6.0.303
Anything else?
WASM
dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.303
Commit: 7494fee64a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.303\
global.json file:
Not found
Host:
Version: 6.0.8
Architecture: x64
Commit: 55fb7ef977
.NET SDKs installed:
3.1.422 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.303 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
The text was updated successfully, but these errors were encountered: