Files
mixtape/Finch/FileStorage/WebRootFileSystem.cs
T
2026-04-07 15:22:10 +02:00

28 lines
573 B
C#

namespace Finch.FileStorage;
public class WebRootFileSystem : PhysicalFileSystem, IWebRootFileSystem
{
protected string PublicPathPrefix { get; }
public WebRootFileSystem(string root, string publicPathPrefix) : base(root)
{
PublicPathPrefix = (publicPathPrefix ?? string.Empty).EnsureEndsWith('/');
}
/// <inheritdoc />
public override string MapToPublicPath(string path)
{
if (path.IsNullOrEmpty())
{
return null;
}
return PublicPathPrefix + path.TrimStart('/');
}
}
public interface IWebRootFileSystem : IFileSystem
{
}