added new api saveFileToDisk and renamed saveToDisk to saveStreamToDisk
This commit is contained in:
parent
24f6d4026f
commit
396ec0fbbc
|
@ -27,12 +27,16 @@ const checkExistsAndCreateCollectionDir = async (dirPath: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
const saveToDisk = (path: string, fileStream: ReadableStream<any>) => {
|
||||
const saveStreamToDisk = (path: string, fileStream: ReadableStream<any>) => {
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue