Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 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 (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-18T12:32:13.000Z (over 1 year ago)
- Last Synced: 2024-10-29T22:53:59.178Z (4 months ago)
- Language: C#
- Size: 8.46 MB
- Stars: 32
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
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.0 or 6.0 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://stefh.github.io/Blazor.DownloadFileFast/