Files
SPT-Server-Build/Libraries/SPTarkov.Server.Core/Utils/HttpFileUtil.cs
T
clodanSPT 1af50bfd34 Application cleanup (#485)
* Changed application to use background services and removed hacky http server startup

* Small improvements and method removals

* Removed Core dependency on Web application SDK

* Fixed wrong imported type

---------

Co-authored-by: Alex <clodanSPT@hotmail.com>
Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
2025-07-18 16:21:24 +01:00

21 lines
673 B
C#

using Microsoft.AspNetCore.Http;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Helpers;
namespace SPTarkov.Server.Core.Utils;
[Injectable]
public class HttpFileUtil(HttpServerHelper httpServerHelper)
{
public async Task SendFile(HttpResponse resp, string filePath)
{
var pathSlice = filePath.Split("/");
var mimePath = httpServerHelper.GetMimeText(pathSlice[^1].Split(".")[^1]);
var type = string.IsNullOrWhiteSpace(mimePath)
? httpServerHelper.GetMimeText("txt")
: mimePath;
resp.Headers.Append("Content-Type", type);
await resp.SendFileAsync(filePath, CancellationToken.None);
}
}