https://github.com/StefH/Blazor.DownloadFileFast
Fast download from files to the browser from Blazor without any javascript library reference or dependency.
https://github.com/StefH/Blazor.DownloadFileFast
Last synced: 5 months ago
JSON representation
Fast download from files to the browser from Blazor without any javascript library reference or dependency.
- Host: GitHub
- URL: https://github.com/StefH/Blazor.DownloadFileFast
- Owner: StefH
- License: mit
- Created: 2020-12-25T09:37:55.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-20T10:31:07.000Z (7 months ago)
- Last Synced: 2025-04-30T21:52:36.776Z (5 months ago)
- Language: C#
- Size: 9.11 MB
- Stars: 39
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-blazor - Blazor.DownloadFileFast -   Fast download of files to the browser from Blazor without any javascript library reference or dependency. ([Demo](https://stefh.github.io/Blazor.DownloadFileFast/)). (Libraries & Extensions / Others)
README
# Blazor.DownloadFileFast
[](https://www.nuget.org/packages/BlazorDownloadFileFast)
Fast download from files to the browser from Blazor without any javascript library reference or dependency.
BlazorDownloadFileFast is the solution to saving files on the client-side, and is perfect for web apps that generates files on the client.
When using this project in a NET 5 (and up) Blazor WebAssembly project, there is an additional speed increase.
Read the blog post mentioned from Gérald Barré in the credits.## Usage
### Register
```c#
builder.Services.AddBlazorDownloadFile();
```### Inject in code-behind
``` c#
[Inject]
public IBlazorDownloadFileService BlazorDownloadFileService { get; set; }
```### Use in your code
``` c#
byte[] bytes = ...;
await BlazorDownloadFileService.DownloadFileAsync("example.txt", bytes);
```## Credits
- The idea and code from this project is based on [Generating and efficiently exporting a file in a Blazor WebAssembly application](https://www.meziantou.net/generating-and-downloading-a-file-in-a-blazor-webassembly-application.htm)
- For resolving the Content-Type based on the file extension, this code is used: [MimeTypeMap](https://github.com/samuelneff/MimeTypeMap)
- This project is inspired by [BlazorDownloadFile](https://github.com/arivera12/BlazorDownloadFile)## Demo
- https://wonderful-glacier-0cf7ba303.4.azurestaticapps.net
- https://stefh.github.io/Blazor.DownloadFileFast/