Blazorme.StreamSaver
26.9.14
dotnet add package Blazorme.StreamSaver --version 26.9.14
NuGet\Install-Package Blazorme.StreamSaver -Version 26.9.14
<PackageReference Include="Blazorme.StreamSaver" Version="26.9.14" />
<PackageVersion Include="Blazorme.StreamSaver" Version="26.9.14" />
<PackageReference Include="Blazorme.StreamSaver" />
paket add Blazorme.StreamSaver --version 26.9.14
#r "nuget: Blazorme.StreamSaver, 26.9.14"
#:package Blazorme.StreamSaver@26.9.14
#addin nuget:?package=Blazorme.StreamSaver&version=26.9.14
#tool nuget:?package=Blazorme.StreamSaver&version=26.9.14
Blazorme.StreamSaver
JSInterop of the StreamSaver package for Blazor. With this package, you can download files by writing incoming data chunks directly to the file instead of accumulating them in memory. This will prevent memory overflows for very large files.
Requires .NET 10. Earlier versions targeted net5.0, which is no longer supported.
Intended for Blazor WebAssembly. It also runs on Blazor Server, but there every chunk crosses the SignalR circuit, which makes it a poor fit for the large transfers this package exists for.
It provides a very simple API:
public interface IStreamSaver
{
Task<Stream> CreateWritableFileStreamAsync(string fileName);
}
With this call, a C# stream will be returned to the caller. The caller can write(append) data chunks to the file by calling the Stream interface WriteAsync call.
After all chunks are written, Close call on the stream will complete the file download.
Installation
- Install NuGet package:
Install-Package Blazorme.StreamSaver
Using
In _Imports.razor add:
@using Blazorme
In a razor file add:
[Inject]
IStreamSaver StreamSaver { get; set; }
From code behind, inject the interface to your constructor:
using Blazorme;
Xxx(IStreamSaver streamSaver, ...)
JS references
Add the following lines to your index.html file:
<script src="_content/Blazorme.StreamSaver/polyfill.min.js"></script>
<script src="_content/Blazorme.StreamSaver/StreamSaver.min.js"></script>
Service addition
Add the following to Program.cs:
using Blazorme;
Main
{
...
builder.Services.AddStreamSaver();
...
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.11)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Blazorme.StreamSaver:
| Package | Downloads |
|---|---|
|
WebRTCme.Middleware
Services layer between Blazor or .NET MAUI applications and the WebRTCme library. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Blazorme.StreamSaver:
| Repository | Stars |
|---|---|
|
melihercan/WebRTCme
A cross-platform framework that enables WebRTC support in .NET MAUI (mobile and desktop) and Blazor applications through a single, unified .NET/C# API.
|
Modernised for .NET 10. Targets net10.0 only; net5.0 is no longer supported.
The JS interop is rebuilt on IJSObjectReference modules, replacing System.Private.Runtime.InteropServices.JavaScript — the .NET 5/6 preview WASM API that was removed in .NET 7 and that this package could not have run without.
Fixed: WriteAsync ignored the offset and count it was given and sent the whole array. Stream.WriteAsync(ReadOnlyMemory) supplies an oversized pooled buffer, so downloads had trailing bytes appended.