KI-AGENT: Dateivorschauen authentifiziert laden

This commit is contained in:
2026-09-07 20:10:18 +02:00
parent 2c7cd17e2b
commit dd063fd648
5 changed files with 126 additions and 18 deletions

View File

@@ -146,6 +146,26 @@ export const useFiles = () => {
}
const openFile = async (id: string) => {
const targetWindow = window.open("about:blank", "_blank")
try {
const blob = await downloadFile(id, undefined, true) as Blob
const objectUrl = URL.createObjectURL(blob)
if (targetWindow) {
targetWindow.location.replace(objectUrl)
} else {
window.open(objectUrl, "_blank")
}
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 60_000)
} catch (error) {
targetWindow?.close()
throw error
}
}
const dataURLtoFile = (dataurl:string, filename:string) => {
let arr = dataurl.split(","),
//@ts-ignore
@@ -160,5 +180,5 @@ export const useFiles = () => {
}
return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument, downloadFile, dataURLtoFile}
return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument, downloadFile, openFile, dataURLtoFile}
}