title: Trying to send a zip from the backend to the frontend
body: <p>At one point in my <code>ember.js</code> webapp the user is given the option to download a zip file. On clicking the button, an action is triggered that sends a request to the backend server, which generates the zip and returns it. Ideally the zip should then be downloaded automatically.</p>
  
  <p>In my backend endpoint I return with</p>
  
  <pre><code>return Response
          .ok(FileUtils.readFileToByteArray(new File(tmpZipFilename))) // tmpZipFilename is a String
          .type("application/zip")
          .header("Content-Disposition", "attachment; filename=\"" + finalZipFilename + "\"")
          .build();
  </code></pre>
  
  <p>In the frontend I have (adapted from <a href="http://www.alexhadik.com/blog/2016/7/7/l8ztp8kr5lbctf5qns4l8t3646npqh" rel="nofollow noreferrer">here</a>)</p>
  
  <pre><code>submit() {
    var formData = new FormData(this);
    let token = this.get('session.data.authenticated.token');
    jquery.ajax({
      url: `myUrl`,
      data: formData,
      processData: false,
      contentType: false,
      beforeSend: function(xhr) {xhr.setRequestHeader('Authorization', `Bearer ${token}`)},
      type: 'POST',
      success: function(data) {
        var blob = new Blob([data], {type: 'application/zip'});
        let a = document.createElement("a");
        a.style = "display: none";
        document.body.appendChild(a);
        let url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = 'myFile.zip';
        a.click();
        window.URL.revokeObjectURL(url);
      },
      failure: function() {
        // other stuff
      }
    })
  }
  </code></pre>
  
  <p>The response headers are the following:</p>
  
  <pre><code>HTTP/1.1 200 OK
  X-Powered-By: Undertow/1
  Cache-Control: no-store
  Date: Tue, 19 Feb 2019 16:34:35 GMT
  Server: WildFly/10
  Content-Type: application/zip
  Content-Disposition: attachment; filename="filename.zip"
  Connection: close
  Transfer-Encoding: chunked
  </code></pre>
  
  <p>I have confirmed that <code>tmpZipFilename</code> in the backend section does correctly point to a proper zip file. And when the user clicks the download button a file called <code>myFile.zip</code> is indeed downloaded. However, the file downloaded is not unzippable and is a different size than the correct file pointed to by <code>tmpZipFilename</code>. What am I doing wrong?</p>