backend + web: Monitor attachment storage and download PDFs

This commit is contained in:
GonnaHetzMe committed 2026-12-04 22:25:00 +01:00
1 parent 4f95c8a379
commit 5470818841
6 files changed
+67 -5

No files matched your search

@@ -8,7 +8,7 @@ namespace Helpdesk.Infrastructure.Files;
internal sealed class FileAttachmentStore(ILogger<FileAttachmentStore> logger) : IAttachmentStore
{
private readonly string directory = Path.Combine(AppContext.BaseDirectory, "uploads");
internal static readonly string UploadDirectory = Path.Combine(AppContext.BaseDirectory, "uploads");
public async Task<StoredAttachment> SaveAsync(AttachmentUpload upload, CancellationToken ct)
{
@@ -30,7 +30,7 @@ internal sealed class FileAttachmentStore(ILogger<FileAttachmentStore> logger) :
_ => throw new BadRequestException("Tento typ přílohy není povolen."),
};
Directory.CreateDirectory(directory);
Directory.CreateDirectory(UploadDirectory);
var key = Guid.NewGuid().ToString("D");
var path = FilePath(key);
@@ -97,7 +97,7 @@ internal sealed class FileAttachmentStore(ILogger<FileAttachmentStore> logger) :
}
private string FilePath(string key) => Guid.TryParseExact(key, "D", out _)
? Path.Combine(directory, key)
? Path.Combine(UploadDirectory, key)
: throw new InvalidOperationException("Neplatný klíč souboru přílohy.");
private static async Task<bool> HasExpectedFormatAsync(Stream stream, string extension, CancellationToken ct)