FileSystemProviders Configuration
Information on FileSystemProviders and how to configure them in Umbraco
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Infrastructure.DependencyInjection;
using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment;
namespace FilesystemProviders;
public class FilesystemComposer : IComposer
{
public void Compose(IUmbracoBuilder builder) =>
builder.SetMediaFileSystem(factory =>
{
IHostingEnvironment hostingEnvironment = factory.GetRequiredService<IHostingEnvironment>();
IWebHostEnvironment webHostEnvironment = factory.GetRequiredService<IWebHostEnvironment>();
var folderLocation = "~/CustomMediaFolder";
var rootPath = webHostEnvironment.MapPathWebRoot(folderLocation);
var rootUrl = hostingEnvironment.ToAbsolute(folderLocation);
return new PhysicalFileSystem(
factory.GetRequiredService<IIOHelper>(),
hostingEnvironment,
factory.GetRequiredService<ILogger<PhysicalFileSystem>>(),
rootPath,
rootUrl);
});
}PhysicalFileSystem Configuration
Virtual Folder
Physical path
Custom providers
Get the contents of a file as a stream
Last updated
Was this helpful?