2021-11-25 15:38:36 +01:00
|
|
|
namespace zero.Media;
|
|
|
|
|
|
|
|
|
|
public class MediaFileSystem : PhysicalFileSystem, IMediaFileSystem
|
|
|
|
|
{
|
|
|
|
|
protected string PublicPathPrefix { get; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MediaFileSystem(string root, string publicPathPrefix) : base(root)
|
|
|
|
|
{
|
|
|
|
|
PublicPathPrefix = (publicPathPrefix ?? String.Empty).EnsureEndsWith('/');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2021-12-03 15:49:34 +01:00
|
|
|
public override string MapToPublicPath(string path)
|
2021-11-25 15:38:36 +01:00
|
|
|
{
|
2022-01-03 13:25:23 +01:00
|
|
|
if (path.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-11-25 15:38:36 +01:00
|
|
|
return PublicPathPrefix + path.TrimStart('/');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-12-03 15:49:34 +01:00
|
|
|
public interface IMediaFileSystem : IFileSystem { }
|