BLOB Storing File System Provider
File System Storage Provider is used to store BLOBs in the local file system as standard files inside a folder.
Read the BLOB Storing document to understand how to use the BLOB storing system. This document only covers how to configure containers to use the file system.
Use the ABP CLI to add Volo.Abp.BlobStoring.FileSystem NuGet package to your project:
- Install the ABP CLI if you haven't installed before.
- Open a command line (terminal) in the directory of the
.csprojfile you want to add the
abp add-package Volo.Abp.BlobStoring.FileSystemcommand.
If you want to do it manually, install the Volo.Abp.BlobStoring.FileSystem NuGet package to your project and add
[DependsOn(typeof(AbpBlobStoringFileSystemModule))] to the ABP module class inside your project.
Example: Configure to use the File System storage provider by default
fileSystem.BasePath = "C:\\my-files";
UseFileSystem extension method is used to set the File System Provider for a container and configure the file system options.
See the BLOB Storing document to learn how to configure this provider for a specific container.
- BasePath (string): The base folder path to store BLOBs. It is required to set this option.
- AppendContainerNameToBasePath (bool; default:
true): Indicates whether to create a folder with the container name inside the base folder. If you store multiple containers in the same
BaseFolder, leave this as
true. Otherwise, you can set it to
falseif you don't like an unnecessarily deeper folder hierarchy.
File Path Calculation
File System Provider organizes BLOB files inside folders and implements some conventions. The full path of a BLOB file is determined by the following rules by default:
- It starts with the
BasePathconfigured as shown above.
hostfolder if current tenant is
null(or multi-tenancy is disabled for the container - see the BLOB Storing document to learn how to disable multi-tenancy for a container).
tenants/<tenant-id>folder if current tenant is not
- Appends the container's name if
true. If container name contains
/, this will result with nested folders.
- Appends the BLOB name. If the BLOB name contains
/it creates folders. If the BLOB name contains
.it will have a file extension.
Extending the File System BLOB Provider
FileSystemBlobProvideris the main service that implements the File System storage. You can inherit from this class and override methods to customize it.
IBlobFilePathCalculatorservice is used to calculate the file paths. Default implementation is the
DefaultBlobFilePathCalculator. You can replace/override it if you want to customize the file path calculation.
Thank you for your valuable feedback!
Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.