Implemented new Backend in E-Mail Sending

Implemented Blob Return Method for File Download
This commit is contained in:
2025-09-12 17:42:24 +02:00
parent 9a210bceb9
commit 30da08689d
2 changed files with 33 additions and 15 deletions

View File

@@ -83,7 +83,7 @@ export const useFiles = () => {
return res.files[0]
}
const downloadFile = async (id?: string, ids?: string[]) => {
const downloadFile = async (id?: string, ids?: string[], returnAsBlob: Boolean = false) => {
const url = id ? `/api/files/download/${id}` : `/api/files/download`
const body = ids ? { ids } : undefined
@@ -109,11 +109,19 @@ export const useFiles = () => {
// Direkt speichern
const blob = res._data as Blob
const link = document.createElement("a")
link.href = URL.createObjectURL(blob)
link.download = filename
link.click()
URL.revokeObjectURL(link.href)
if(returnAsBlob) {
return blob
} else {
const link = document.createElement("a")
link.href = URL.createObjectURL(blob)
link.download = filename
link.click()
URL.revokeObjectURL(link.href)
}
}