update to file save dialog
This commit is contained in:
parent
bf9a9c5f9f
commit
0d69c3f266
|
@ -3,6 +3,7 @@ import {
|
||||||
remote,
|
remote,
|
||||||
shell,
|
shell,
|
||||||
} from 'electron';
|
} from 'electron';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isDev,
|
isDev,
|
||||||
|
@ -113,13 +114,13 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
|
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
|
||||||
const blob = new Blob([blobData], blobOptions);
|
remote.dialog.showSaveDialog(remote.getCurrentWindow(), {
|
||||||
const a = win.document.createElement('a');
|
defaultPath: fileName,
|
||||||
a.href = win.URL.createObjectURL(blob);
|
}, (filename) => {
|
||||||
a.download = fileName;
|
fs.writeFile(filename, Buffer.from(blobData), (err) => {
|
||||||
window.document.body.appendChild(a);
|
// error check?
|
||||||
a.click();
|
});
|
||||||
window.document.body.removeChild(a);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplicationVersion(): string {
|
getApplicationVersion(): string {
|
||||||
|
|
Loading…
Reference in New Issue