Custom File Systems (IFileSystem)
A guide to creating custom file systems in Umbraco
Media Filesystem
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Infrastructure.DependencyInjection;
namespace UmbracoExamples.Composition;
public class SetMediaFileSystemComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.SetMediaFileSystem((factory) =>
{
IHostingEnvironment hostingEnvironment = factory.GetRequiredService<IHostingEnvironment>();
var folderLocation = "~/CustomMediaFolder";
var rootPath = hostingEnvironment.MapPathWebRoot(folderLocation);
var rootUrl = hostingEnvironment.ToAbsolute(folderLocation);
return new PhysicalFileSystem(
factory.GetRequiredService<IIOHelper>(),
hostingEnvironment,
factory.GetRequiredService<ILogger<PhysicalFileSystem>>(),
rootPath,
rootUrl);
});
}
}Creating a custom file system
Accessing the media file system from code
MediaPath Scheme
Other IFileSystems
Stylesheet Filesystem
Custom providers
Last updated
Was this helpful?