BlazorBlobStream 1.1.1

dotnet add package BlazorBlobStream --version 1.1.1
                    
NuGet\Install-Package BlazorBlobStream -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorBlobStream" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorBlobStream" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="BlazorBlobStream" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorBlobStream --version 1.1.1
                    
#r "nuget: BlazorBlobStream, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BlazorBlobStream@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorBlobStream&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=BlazorBlobStream&version=1.1.1
                    
Install as a Cake Tool

BlazorBlobStream

A seekable File stream for Blazor.

Nuget (with prereleases) GitHub license

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:

  1. Install this NuGet package:
dotnet add package BlazorBlobStream
  1. Register the BlobStreamService in Program.cs:
using BlazorBlobStream;
...
builder.Services.AddTransient<BlobStreamService>();
  1. 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);
    }
}
  1. Seek freely!
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 879 1/24/2024
1.1.0 114 1/24/2024
1.0.2 125 1/18/2024
1.0.1 127 1/16/2024
1.0.0 128 1/16/2024