BlazorBlobStream 1.1.1
dotnet add package BlazorBlobStream --version 1.1.1
NuGet\Install-Package BlazorBlobStream -Version 1.1.1
<PackageReference Include="BlazorBlobStream" Version="1.1.1" />
<PackageVersion Include="BlazorBlobStream" Version="1.1.1" />
<PackageReference Include="BlazorBlobStream" />
paket add BlazorBlobStream --version 1.1.1
#r "nuget: BlazorBlobStream, 1.1.1"
#:package BlazorBlobStream@1.1.1
#addin nuget:?package=BlazorBlobStream&version=1.1.1
#tool nuget:?package=BlazorBlobStream&version=1.1.1
BlazorBlobStream
A seekable File stream for Blazor.
This is an alternative implementation of Microsoft.AspNetCore.Components.Forms.IBrowserFile
.
The stream returned by OpenReadStream
now supports setting the Position
property and calling the Seek
method.
Why
The MS provided implementation of IBrowserFile
returns a stream that doesn't allow seeking.
If you need to seek in this stream, you are left with the only option of copying the whole stream into the memory.
How
All browsers support seeking in Files by slicing the Blob. This implementation uses blob-slicing to support seeking in Blazor.
Usage
To get seekable file streams, you just have to:
- Install this NuGet package:
dotnet add package BlazorBlobStream
- Register the
BlobStreamService
inProgram.cs
:
using BlazorBlobStream;
...
builder.Services.AddTransient<BlobStreamService>();
- Inject and call the
BlobStreamService
in razor page:
@inject BlazorBlobStream.BlobStreamService BlobStreamService
<InputFile @ref="inputFile" OnChange="OnFileChange"/>
@code {
InputFile inputFile = default!;
async Task OnFileChange(InputFileChangeEventArgs fileChange)
{
var browserFiles = await BlobStreamService.GetBrowserFilesAsync(inputFile);
var browserFile = browserFiles.First();
await using var fileStream = browserFile.OpenReadStream(maxAllowedSize: browserFile.Size);
}
}
- Seek freely!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.