Files
SPT-Server-Build/Libraries/SPTarkov.Server.Core/Utils/HttpFileUtil.cs
T
Chomp 040be2feaa More strings to MongoIds
Convert constructors into primary constructors

Simplified logic with use of ??, ??= and method groups

Cleaned up redundant conditional access qualifiers
2025-07-14 22:29:41 +01:00

20 lines
640 B
C#

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);
}
}