I am writing a NodeJS Electron App to be distributed on all platforms. I have a download button that I would like to pop open a Save As dialog with the file being provided from
Below is an example if you want to use renderer only. On click Electron will show standard browser's Save As dialog. No need of remote
nor fs
.
In the renderer javascript file:
// renderer javascript file
function saveFile() {
const content = "File content to save";
const element = document.createElement("a");
const file = new Blob([content], {type: "text/plain"});
element.href = URL.createObjectURL(file);
element.download = "file.txt";
element.click();
}
(I'm on mac and haven't tried it on a Windows machine)