diff --git a/src/preload.ts b/src/preload.ts index 14b16e748..278ba8846 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -27,12 +27,16 @@ const checkExistsAndCreateCollectionDir = async (dirPath: string) => { } }; -const saveToDisk = (path: string, fileStream: ReadableStream) => { +const saveStreamToDisk = (path: string, fileStream: ReadableStream) => { const writeable = fs.createWriteStream(path); const readable = responseToReadable(fileStream); readable.pipe(writeable); }; +const saveFileToDisk = async (path: string, file: any) => { + await fs.writeFile(path, file); +}; + const selectRootDirectory = async () => { try { return await ipcRenderer.sendSync('select-dir'); @@ -76,7 +80,8 @@ const showOnTray = (item: any[]) => { var windowObject: any = window; windowObject['ElectronAPIs'] = { checkExistsAndCreateCollectionDir, - saveToDisk, + saveStreamToDisk, + saveFileToDisk, selectRootDirectory, updateExportRecord, getExportedFiles,