Files
mixtape/Finch/FileStorage/FinchFileStorageModule.cs
T

24 lines
794 B
C#
Raw Normal View History

2022-12-07 14:05:11 +01:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2026-04-07 14:23:29 +02:00
namespace Finch.FileStorage;
2022-12-07 14:05:11 +01:00
2026-04-07 14:23:29 +02:00
internal class FinchFileStorageModule : FinchModule
2022-12-07 14:05:11 +01:00
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IPaths>(factory => new Paths(factory.GetService<IWebHostEnvironment>()));
2026-04-07 14:23:29 +02:00
services.AddOptions<FileSystemOptions>().Bind(configuration.GetSection("Finch:FileSystem")).Configure(opts =>
2022-12-07 14:05:11 +01:00
{
2026-04-07 14:23:29 +02:00
opts.FinchAssetsPath = "finch";
2022-12-07 14:05:11 +01:00
});
services.AddSingleton<IWebRootFileSystem, WebRootFileSystem>(svc =>
{
IWebHostEnvironment env = svc.GetRequiredService<IWebHostEnvironment>();
return new(env.WebRootPath, null);
});
}
}