A Blazor interop library for the file upload library FilePond
$ dotnet add package Soenneker.Blazor.FilePond
Soenneker.Blazor.FilePondThis library simplifies the integration of FilePond into Blazor applications, providing access to options, methods, plugins, and events. A demo project showcasing common usages is included.
Diligence was taken to align the Blazor API with JS. Refer to the FilePond documentation for details.
dotnet add package Soenneker.Blazor.FilePond
_Imports.razor file@using Soenneker.Blazor.FilePond
Startup.cs filepublic void ConfigureServices(IServiceCollection services)
{
services.AddFilePond();
}
wwwroot/index.html file<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/filepond@4.30.6/dist/filepond.min.css">
wwwroot/index.html file<script src="https://cdn.jsdelivr.net/npm/filepond@4.30.6/dist/filepond.min.js"></script>
<script src="_content/Soenneker.Blazor.FilePond/filepondinterop.js"></script>
<FilePond @ref="FilePond" Options="_options" OnAddFile="OnAddFile"></FilePond>
@code{
private FilePond? FilePond { get; set; }
private readonly FilePondOptions _options = new()
{
MaxFiles = 20,
AllowMultiple = true
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// Add any plugins you want to use
//await FilePond!.EnablePlugins(FilePondPluginType.FileValidateType, FilePondPluginType.ImagePreview);
}
}
private async Task OnAddFile((FilePondError? error, FilePondFileItem fileItem) obj)
{
Logger.LogInformation("OnAddFile fired: Filename: {fileName}", obj.fileItem.Filename);
Stream? stream = await FilePond!.GetStreamForFile();
// do something with the stream
await stream.DisposeAsync();
}
}
⚠️ While 95%+ of the FilePond JS has been implemented, there are a few features not yet supported. If you need assistance or want to request a new feature, please open an issue or submit a pull request.