mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-07 08:22:42 +08:00
28 lines
756 B
C#
28 lines
756 B
C#
using Microsoft.Extensions.FileProviders;
|
|
using Scalar.AspNetCore;
|
|
|
|
namespace Foxel.Extensions;
|
|
|
|
public static class ApplicationBuilderExtensions
|
|
{
|
|
public static void UseApplicationStaticFiles(this WebApplication app)
|
|
{
|
|
var uploadsPath = Path.Combine(Directory.GetCurrentDirectory(), "Uploads");
|
|
if (!Directory.Exists(uploadsPath))
|
|
{
|
|
Directory.CreateDirectory(uploadsPath);
|
|
}
|
|
|
|
app.UseStaticFiles(new StaticFileOptions
|
|
{
|
|
FileProvider = new PhysicalFileProvider(uploadsPath),
|
|
RequestPath = "/Uploads"
|
|
});
|
|
}
|
|
|
|
public static void UseApplicationOpenApi(this WebApplication app)
|
|
{
|
|
app.MapOpenApi();
|
|
app.MapScalarApiReference();
|
|
}
|
|
} |