Toolbelt.Blazor.InvokeDownloadAsync 3.0.0

dotnet add package Toolbelt.Blazor.InvokeDownloadAsync --version 3.0.0                
NuGet\Install-Package Toolbelt.Blazor.InvokeDownloadAsync -Version 3.0.0                
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="Toolbelt.Blazor.InvokeDownloadAsync" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Toolbelt.Blazor.InvokeDownloadAsync --version 3.0.0                
#r "nuget: Toolbelt.Blazor.InvokeDownloadAsync, 3.0.0"                
#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.
// Install Toolbelt.Blazor.InvokeDownloadAsync as a Cake Addin
#addin nuget:?package=Toolbelt.Blazor.InvokeDownloadAsync&version=3.0.0

// Install Toolbelt.Blazor.InvokeDownloadAsync as a Cake Tool
#tool nuget:?package=Toolbelt.Blazor.InvokeDownloadAsync&version=3.0.0                

Blazor InvokeDownloadAsync NuGet Package

Summary

This NuGet package simply adds the InvokeDownloadAsync() extension method on your Blazor apps.

@inject IJSRuntime JSRuntime

<button @onclick="BeginDownloadAsync">
  Begin Download
</button>
...
@code
{
  ...
  private async Task BeginDownloadAsync()
  {
    ...
    await this.JSRuntime.InvokeDownloadAsync(
      "Foo.png",
      "image/png",
      pictureBytes);
  }
}

alternate text is missing from this package README image

Highlights

1. Minimal setup

This package is an extension method for the IJSRuntime interface. You can use the downloading feature immediately if there is a JavaScript runtime object. You don't need to write any code in your startup.

2. Small package size

This package is simple and small content size because this package doesn't have massive code optimized for performance.

Usage

Install this NuGet package to your Blazor application project.

dotnet add package Toolbelt.Blazor.InvokeDownloadAsync

After that, you can use the InvokeDownloadAsync() extension method for the IJSRuntime interface.

Syntax

ValueTask InvokeDownloadAsync(
      this IJSRuntime jsRuntime,
      string fileName,
      string contentType,
      byte[] contentBytes);
ValueTask InvokeDownloadAsync(
      this IJSRuntime jsRuntime,
      string fileName,
      string contentType,
      Stream contentStream,
      bool leaveOpen = false);

IImplicit using the namespace

To use the InvokeDownloadAsync() extension method it requires open the namespace Toolbelt.Blazor.Extensions.Downloading. But in a general case, you don't need to open the namespace Toolbelt.Blazor.Extensions.Downloading explicitly because the NuGet package opens it implicitly by default.

To prevent this default behavior, please set the ImplicitUsingsToolbeltBlazorExtensionsDownloading MSBuild property to false.


<Project>
  ...
  <PropertyGroup>
    ...
    <ImplicitUsingsToolbeltBlazorExtensionsDownloading>false</ImplicitUsingsToolbeltBlazorExtensionsDownloading>
    ...

Release notes

Release notes is here.

License

MIT License

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 is compatible.  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. 
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
3.0.0 107 10/3/2024
2.0.0 1,983 10/17/2022
1.1.0 415 10/14/2022
1.0.0 557 6/23/2022

v.3.0.0
- BREAKING CHANGE: Drop support for .NET 5.0.
- Imporve: Content Security Policy (CSP) support.
- Fix: Some performance issues.


To see all the change logs, please visit the following URL.
- https://github.com/jsakamoto/Toolbelt.Blazor.InvokeDownloadAsync/blob/main/RELEASE-NOTES.txt