mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-05-31 21:20:52 +08:00
Initial commit
This commit is contained in:
27
Extensions/ApplicationBuilderExtensions.cs
Normal file
27
Extensions/ApplicationBuilderExtensions.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user