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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user