Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/soenneker/soenneker.blazor.filepond

A Blazor interop library for the file upload library FilePond
https://github.com/soenneker/soenneker.blazor.filepond

blazor csharp dotnet file filepond filepondinterop interop upload

Last synced: about 3 hours ago
JSON representation

A Blazor interop library for the file upload library FilePond

Awesome Lists containing this project

README

        

[![](https://img.shields.io/nuget/v/soenneker.blazor.filepond.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.filepond/)
[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.filepond/publish-package.yml?style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.filepond/actions/workflows/publish-package.yml)
[![](https://img.shields.io/nuget/dt/soenneker.blazor.filepond.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.filepond/)

# ![](https://user-images.githubusercontent.com/4441470/224455560-91ed3ee7-f510-4041-a8d2-3fc093025112.png) Soenneker.Blazor.FilePond
### A Blazor interop library for the file upload library [FilePond](https://pqina.nl/filepond/)

This 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](https://pqina.nl/filepond/docs/) for details.

## Installation

```
dotnet add package Soenneker.Blazor.FilePond
```

### Add the following to your `Startup.cs` file

```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddFilePond();
}
```

⚠ Do not include styles or scripts on the page as they get lazily injected automatically, including most plugins.

## Usage

```razor
@using Soenneker.Blazor.FilePond

@code{
private FilePond? FilePond { get; set; }

private readonly FilePondOptions _options = new()
{
MaxFiles = 20,
AllowMultiple = true,
EnabledPlugins = [FilePondPluginType.ImagePreview]
};

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await FilePond.AddFile("https://picsum.photos/500/500");
}
}

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();
}
}
```