Fixed Dokubox and Sanitizing for File Uploads Fix #133

This commit is contained in:
2026-03-18 18:27:14 +01:00
parent 69ff646689
commit 003d88587a
3 changed files with 14 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import { files } from "../../db/schema"
import { eq } from "drizzle-orm"
import { FastifyInstance } from "fastify"
import { storeExtractedTextForFile } from "./documentText"
import { sanitizeFilename } from "./filename"
export const saveFile = async (
server: FastifyInstance,
@@ -46,7 +47,10 @@ export const saveFile = async (
// Name ermitteln (Fallback Logik)
// Wenn attachment ein Buffer ist, muss der Name in 'other' stehen oder generiert werden
const filename = attachment.filename || providedFilename || `${created.id}.pdf`
const filename = sanitizeFilename(
attachment.filename || providedFilename || `${created.id}.pdf`,
`${created.id}.pdf`
)
// ---------------------------------------------------
// 2⃣ BODY & CONTENT TYPE ERMITTELN
@@ -108,7 +112,7 @@ export const saveFile = async (
)
console.log(`File saved: ${key}`)
return { id: created.id, key }
return { id: created.id, key, filename }
} catch (err) {
console.error("saveFile error:", err)
return null