The Local File Storage handles uploaded media by storing the uploaded files on the webserver. The default directory for uploaded files is
As media files are stored together with the web application running the manager interface, the storage is best suited for simple applications where all components are run in the same web application. For more complex runtime scenarios a more distributed storage service is better.
The Local File Storage can be installed by adding the NuGet package:
PM> install-package Piranha.Local.FileStorage
You register Local File Storage with the default configuration in
ConfigureServices() with the following code:
When registering the service you have access to some configuration options to customize the storage to your needs.
The path where media files are uploaded. The default value is
The base url where local files can be downloaded. Please note that there's no rewriting made for requested URL's so the provided value must match the structure of the file system. The default value is
services.AddPiranhaFileStorage(basePath: "wwwroot/media", baseUrl: "~/media/");
By default the service is registered as a
Singleton, but in some cases you might want to handle it differently in your application.