title: Angular 13 - Download file from ByteArray data
body: <p>I get a <code>byte[]</code> file from my server with the content of a file. I know the name and the <code>content-type</code>. So far I have tried the following for downloading the file:</p>
  
  <pre><code>const a = document.createElement('a');
  document.body.appendChild(a);
  a.style.display = 'none';
  
  const file = new Blob([content], {type: 'text/plain'});
  const url = window.URL.createObjectURL(file);
  a.href = url;
  a.download = "test.txt";
  a.click();
  window.URL.revokeObjectURL(url);
  </code></pre>
  
  <p>But this solution just downloads a text file with the binary content in it. How can I convert the binary data to the correspondent file type in the client side using JavaScript/Typescript? Thanks!</p>