I am developing a node-webkit application. I would like to download a .swf file when I clicked a button and automatically save it to a specific directory. Right now, I can download it but a "save as" dialog is prompting. Is it possible to disable it and just automatically save it? Is this possible with javascript?

2

There are 2 best solutions below

6
SpoonMeiser On BEST ANSWER

No. Otherwise malicious websites would be able to overwrite important files on your computer

1
smendou On

Node Webkit Apps are not Website, therefore yes, you can do so by using a node module. For example, using fs (File system) :

var fs = require("fs");
fs.writeFile("myfile.txt", "Yes! with nwjs i can do stuff that i'm not allowed to do in browser!", function(err) {
  if(err)console.log(err)
  else console.log("file saved");
});

Maybe you can read the content of your downloaded file and pipe it to where you want :

fs.createReadStream(source_file_path).pipe(fs.createWriteStream(dest_file_path))

You are not restricted as in the browser.