title: NW JS - Download and Save a File from URL
body: <p>I recently started developing Desktop Apps using NW.JS and I need to download a file from a URL (<a href="http://someurl.org/file.zip" rel="nofollow">http://someurl.org/file.zip</a>) and I manage to save the file but it seems corrupted or malformed and I can't open the zip or unzip it.</p>
  
  <p>I'm using jQuery to download the file and the 'fs' module from Node.JS to save it.</p>
  
  <p>Here is the ajax request:</p>
  
  <pre><code>module.exports.download = function (jQuery, url) {
  
      return jQuery.ajax({
          url         : url,
          timeout     : 1000000
      });
  
  };
  </code></pre>
  
  <p>Here is the rest:</p>
  
  <pre><code>$('#btnUpdateClient')
              .click(function () {
                  ClientDownload
                      .download($, addresses.CLIENT_URL)
                      .complete(function (xhr, status) {
                          console.log(xhr);
                          fs.writeFile('./files/staClient.zip', xhr.responseText, function (err) {
  
                              if(err) {
                                  alert('error!');
                                  console.log(err);
                              } else {
                                  alert('file Saved!');
                              }
  
                          });
                      });
              });
  </code></pre>
  
  <p>Something is clearly missing, AND the .zip file is 3.8 MB but when I fs.writeFile() the file ends up being 7.3 MB</p>
  
  <p>I'm fairly new to NW.JS, any advice?</p>