title: Ask user where to save file with Node.js
body: <p>I'm creating an app using node-webkit, so there's a lot of javascript.  I have written a node.js function that will take a screen shot and save it to the disk, however, it saves it to the project root dir and I would like to prompt the user to choose a save location, but I cannot find a way to create a save file dialog.  Current code:</p>
  
  <p>screen_shot.js:</p>
  
  <pre><code>var fs = require('fs');
  exports.buildFile = function(name, value) {
      var img = new Buffer(value, encoding='base64');
      fs.writeFile(name, img, function(err) {
          if(err) {
              console.log(err);
          } else {
              console.log("The file was saved!");
          }
      });
  };
  </code></pre>
  
  <p>index.html:</p>
  
  <pre><code>...
      &lt;script&gt;
          var sc= require('screen_shot');
  
          function wait() {
              $('#close-popup').click();
              setTimeout(function() {screen_shot()}, 10);
          }
  
          function screen_shot() {
              html2canvas($('body'), {
                onrendered: function(canvas) {
                    var img = canvas.toDataURL("image/png").split(',')[1];
                    var decodedImg = window.atob(img);
                    sc.buildFile("sc.png", img);
                }
              });
          }
      &lt;/script&gt;
  ...
  
  &lt;a href="#" onclick="wait();" data-role="button" data-theme="j"&gt;Screen shot&lt;/a&gt;
  </code></pre>
  
  <p>The wait function is just to give the popup I'm using time to close before the screenshot is taken.</p>
  
  <p>I have been reading the <a href="https://github.com/rogerwang/node-webkit/wiki/File-dialogs">node-webkit file dialog doc</a> but it is either not what I'm looking for or I cannot make it work properly.</p>