How to Save As using Node-Webkit

Using Node-Webkit, The following page,

https://github.com/rogerwang/node-webkit/wiki/File-dialogs

Describes that you can use [input type="file" nwsaveas="filename.txt" /] to open a File Save dialog.

However it does not explain how would you write the data to the filesystem.

I expected/imagined something simple like,

var directory = FileOpen();
fs.writeFile(directory+"myfile.png", buffer);

Is there any explanation for this?

You are right, after you trigger the Save As dialog, you will be prompted a dialog, specify the name, and you could receive the file path by doing this.

Sample Code (using jQuery):

$("#save").trigger("click");
$("#save").on("change", function () {
  var filePath = $(this).val();

  if (filePath !== "") {
    var fs = require("fs");
    fs.writeFile(filePath, "Hello World", function (err) {
      if (err) 
        alert("Unable to save file");
      else 
        console.log("saved. ");
    });
  }
  else {
    // User cancelled 
  }
});