Live demo | Full example on GitHub
Your Blazor app lets people save a file for offline use. It works with a 2 MB photo. Then someone picks a 200 MB video, and your app has to find 200 MB of .NET memory to hold it.
Most of the time the app does not need those bytes in .NET at all. It only wants them moved from one place to another. The browser can do that itself.
This article saves the same file two ways and compares the .NET memory each one takes. You need the .NET 10 SDK and a browser.
Where the file goes
The origin private file system (OPFS) is file storage that belongs to your site. It needs no permission prompt, and other sites cannot read it. It does not show up as a normal folder on the user's disk.
Set up
dotnet new blazorwasm -o LargeFiles --empty cd LargeFiles dotnet add package SpawnDev.SpawnJS dotnet add package SpawnDev.SpawnJS.Blazor
Enter fullscreen mode
Exit fullscreen mode
Replace Program.cs :
using LargeFiles ; using Microsoft . AspNetCore . Components . WebAssembly .…