title: Upload Excel to Slack using files.upload API - file uploads, but is corrupted
body: <p>I'm using Slack's <em>files.upload</em> API to upload an Excel doc retrieved from an AJAX response.  I'm using jQuery's AJAX for the upload and the file is uploading correctly except that it's corrupted.  When I open the file downloaded from Slack, it contains many "?"s and other characters indicative of bad encoding.  Downloading the file and then uploading using Slack's <a href="https://api.slack.com/methods/files.upload/test" rel="nofollow noreferrer">tester tool</a>, works correctly and does not result in corruption.</p>
  
  <p>The most relevant portion is the <code>ajaxConfig</code>; this is the object passed to jQuery's <code>ajax()</code> method.</p>
  
  <pre class="lang-js prettyprint-override"><code>self.getClient().runReport({
      query: queryString,
      success: function(response){
          var formEnc = new FormData();
          formEnc.append('file', new Blob([response], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}), 'filename.xls');
          self.getClient().slackFile({
              filename: 'MyReport.xls',
              channel: '%23my-channel',
              ajaxConfig: {
                  method: 'post',
                  data: formEnc,
                  processData: false,
                  contentType: false,
                  mimeType: 'multipart/form-data',
                  success: function(response){
                      resolve(response);
                  },
                  error: function(response){
                      reject(response);
                  }
              }
          });
      },
      error: function(msg){
          reject(msg);
      }
  });
  </code></pre>
  
  <p>I've tried different types for the <code>Blob</code> and the <code>mimeType</code> without success, though I don't think this is the problem because the POST request that I'm sending looks the same as the one generated by Slack's tester tool (which uploaded the file without corruption).  I suspect that the problem must be in how I'm encoding the response I get from <code>runReport</code> (remember that I can download that file manually just fine).</p>
  
  <hr>
  
  <p><strong>Update</strong>
  I used <a href="https://github.com/eligrey/FileSaver.js" rel="nofollow noreferrer">FileSaver.js</a> to download the response and the file is corrupted in the same way, so it's not related to the POST to Slack.  It must be the encoding.</p>