File-Upload: Attachments-Tabelle, Base64-Speicherung, Frontend mit Drag&Drop/Paste/Preview, Error-Handling Fix
This commit is contained in:
1 parent
680f1d6fe2
commit
1271c9c651
11 files changed
+513
-11
No files matched your search
@@ -18,6 +18,7 @@ public static class HistoryEndpoint
|
||||
app.MapPost("/api/archive", HandleArchive);
|
||||
app.MapGet("/api/archives", HandleListArchives);
|
||||
app.MapGet("/api/archive/{archiveId}", HandleGetArchive);
|
||||
app.MapGet("/api/attachments/{messageId}", HandleGetAttachments);
|
||||
}
|
||||
|
||||
private static async Task HandleHistory(HttpContext ctx, DatabaseService db)
|
||||
@@ -89,6 +90,34 @@ public static class HistoryEndpoint
|
||||
await ctx.Response.WriteAsJsonAsync(archives);
|
||||
}
|
||||
|
||||
private static async Task HandleGetAttachments(HttpContext ctx, DatabaseService db)
|
||||
{
|
||||
var messageIdStr = ctx.Request.RouteValues["messageId"]?.ToString();
|
||||
if (!long.TryParse(messageIdStr, out var messageId))
|
||||
{
|
||||
ctx.Response.StatusCode = 400;
|
||||
return;
|
||||
}
|
||||
|
||||
var attachments = await db.GetAttachments(messageId);
|
||||
// Ohne Base64-Data zurückgeben (zu groß), stattdessen als separater Download
|
||||
var result = new List<object>();
|
||||
foreach (var att in attachments)
|
||||
{
|
||||
result.Add(new
|
||||
{
|
||||
att.Id,
|
||||
att.MessageId,
|
||||
att.Type,
|
||||
att.MediaType,
|
||||
att.FileName,
|
||||
att.Data,
|
||||
att.CreatedAt
|
||||
});
|
||||
}
|
||||
await ctx.Response.WriteAsJsonAsync(result);
|
||||
}
|
||||
|
||||
private static async Task HandleGetArchive(HttpContext ctx, DatabaseService db)
|
||||
{
|
||||
var archiveId = ctx.Request.RouteValues["archiveId"]?.ToString();
|
||||
|
||||
Reference in new issue
Block a user