title: Can not open zip file after downloading through nodejs application because of Invalid CEN error
body: <p>I need to download and unzip zip archive in my nodejs application. I have this code:</p>
  
  <pre><code>utils.apiRequest(teamcityOptions)
          .then(function (loadedData) {
            var tempDir = tmp.dirSync();
            var tmpZipFileName = tempDir.name + "\\" + 'bob.zip';
  
            fs.appendFileSync(tmpZipFileName, loadedData);
  
            var zip;
            try {
              zip = new AdmZip(tmpZipFileName);
            } catch (e) {
              log('Can not create zip, bad data', e);
            }
          });
  </code></pre>
  
  <p>This code gives me error:</p>
  
  <blockquote>
    <p>Can not create zip, bad data Invalid CEN header (bad signature)</p>
  </blockquote>
  
  <p>I am using Windows 7. I can't even open this ZIP file with 7-zip or WinRAR (simple error like corrupted data).</p>
  
  <p>Also, <code>utils.apiRequest</code> function body is:</p>
  
  <pre><code>utils.apiRequest: function (options) {
    var deferred = defer();
    https.get(options, function (request) {
      var loadedData = '';
      request.on('data', function (dataBlock) {
        loadedData += dataBlock.toString('utf8');
      });
      request.on('end', function () {
        deferred.resolve(loadedData);
      })
    });
    return deferred.promise;
  }
  </code></pre>
  
  <p>How can I solve my problem?</p>
  
  <p>PS: I don't have problems using <code>curl</code> :)</p>