E-Mail PDF-Downloads als Binärdaten stabilisieren

KI-AGENT: Attachment-Downloads werden im Backend explizit als Buffer mit Content-Length ausgeliefert und im Frontend aus einem ArrayBuffer als Blob erzeugt, damit PDF-Anhänge unverändert gespeichert werden.
This commit is contained in:
2026-05-23 20:52:22 +02:00
parent 8697810127
commit 4fd2eb9c40
3 changed files with 16 additions and 6 deletions

View File

@@ -457,13 +457,14 @@ async function downloadAttachment(attachment: NonNullable<EmailMessage["attachme
actionLoading.value = `attachment-${attachment.id}`
try {
const response = await $fetch.raw(`/api/email/attachments/${attachment.id}/download`, {
responseType: "blob",
responseType: "arrayBuffer",
credentials: "include",
headers: {
...(useCookie("token").value ? { Authorization: `Bearer ${useCookie("token").value}` } : {}),
},
})
const blob = response._data as Blob
const contentType = response.headers.get("content-type") || attachment.contentType || "application/octet-stream"
const blob = new Blob([response._data as ArrayBuffer], { type: contentType })
const disposition = response.headers.get("content-disposition") || ""
const dispositionFilename = disposition.match(/filename="([^"]+)"/)?.[1]
const filename = dispositionFilename || attachment.filename || "anhang"