title: File download a byte array as a file in javascript / Extjs
body: <p>In my Ext Js solution I am calling a service which is returning this JSON format </p>
  
  <pre><code>{"success":true,"filename":"spreadsheet.xlsx","file":[80,75,3,4,20,0,...(many more)]}
  </code></pre>
  
  <p>How can I make a file download dialog with the filename and the content of the byte array (file) ?</p>
  
  <p>UPDATE</p>
  
  <p>So I found this bit to start the downlaod</p>
  
  <pre><code>var a = window.document.createElement('a');
                      a.href = window.URL.createObjectURL(new Blob(data.file, { type: 'application/octet-stream' }));
                      a.download = data.filename;
  
                      // Append anchor to body.
                      document.body.appendChild(a)
                      a.click();
  
                      // Remove anchor from body
                      document.body.removeChild(a)
  </code></pre>
  
  <p>So far good</p>
  
  <p>But the file I get is corrupted so I suspect I need to Encode/Decode the file variable?</p>