FileBlazor Managed File Upload Example

ServiceStack's FileUploadFeature provides an easy and flexible way to create API services backed by either popular cloud solutions like AWS S3, Azure Blob Storage, or your own file system.

Introducing FileUploadFeature Plugin

The FileUploadFeature plugin provides an easy and flexible solution to quickly create APIs services for uploading/downloading files to a variety of storage types which are explored in this demo.

Configuration of IVirtualFiles and FileUploadPlugin.

By utilizing AutoQuery and Locode features, you also get a generated UI to use for back office staff or to use for prototyping. In this demo we configure three different storage types which integrate directly with your own database tables.

  • AWS S3 Bucket
  • Azure Blob Storage Container
  • Local Application File System
Define your database tables to store file metadata.

The FileUploadFeature plugin uses the ServiceStack IVirtualFiles abstraction where multiple named providers can be used and referenced against your database model. Your own database stores metadata about each file including a reference to HTTP file path where the file where it can be downloaded.

Driven by your request DTOs

Your table data for the files in this demo are then shared using AutoQuery services. AutoQuery provides the overridable service implementation to manage this data, this is where you can link your FileUploadFeature to specific table data using the `UploadTo` attribute.

Define your request Data Transfer Objects (DTOs) and use `UploadTo` with the related named UploadLocation.

Upload Files Using Locode

ServiceStack Locode App integrates with the FileUploadFeature plugin to enable a way to manage your files straight away.

Instant upload form using Locode App.

Overridable filters in the plugin

The UploadFeaturePlugin provides overridable options to better control upload/download rules. In this demo, `Public`, `Team` and `Private` files are stored in single table for each upload location. Access rules are configured for each of the upload locations independently using the following plugin options.

  • readAccessRole - Can limit read access to specific user roles.
  • resolvePath - Control how the upload path is created.
  • validateUpload - Filter upload requests.
  • validateDownload - Filter download requests.

Integrate API services with a custom UI

Since AutoQuery services are ServiceStack services, they benefit from being highly interoperable. This FileBlazor demo uses native Blazor components to upload to the generated API services providing a user friendly drag and drop interface.

Navigate to the public S3, Azure or File System file galleries on the left to preview files without authenticating, or login to see the different file access types and upload files yourself.