title: How can I create a file object through byte array
body: <p>I got this array from file[0] -&gt; blob.slice -&gt; filereader.asArrayBuffer -&gt;  Uint8Array</p>
  <blockquote>
  <p>array = [37, 80, 68, 70, 45, 49, 46, 51, 13, 10, 37, 226, 227, 207, 211, 13, 10, 13, 10, 49, 32, 48, 32, 111, ...]</p>
  </blockquote>
  <p>How could I do the reverse engineer? Create a new File Object from the above array?</p>
  <p>I'm creating a file object through</p>
  <blockquote>
  <p>bytes =  [37, 80, 68, 70, 45, 49, 46, 51, 13, 10, 37, 226, 227, 207, 211, 13, 10, 13, 10, 49, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 13, 10, 47, 84, 121, 112, 101, 32, 47, 67, 97, 116, 97, 108, 111, 103, 13, 10, 47, 79, 117, 116, 108, 105, 110, 101, 115, 32, 50, 32, 48, 32, 82, 13, 10, 47, 80, 97, 103, 101, 115, 32, 51, 32, 48, 32, 82, 13, 10, 62, 62, 13, 10, 101, 110, 100, 111, 98, 106, 13, 10, 13, 10, 50, 32, 48, 32, 111, 98, 106]</p>
  <p>let testFile  = new File([bytes],&quot;application/pdf&quot;)</p>
  <p>let testFile  = new File(bytes,&quot;application/pdf&quot;)</p>
  </blockquote>
  <p>Is my code making sense? If not, how do I convert those bytes into a correct one?</p>
  <h1>Uncaught TypeError: Cannot read property 'toString' of undefined</h1>
  <pre><code>content = Uint8Array.from([37, ... 106])
  
  file = new File([content])
  
  reader.readAsArrayBuffer(file);
  
  reader.onload = function (e) {
      const fileType = doTask(e.target.result);
      
  }
  
  function doTask(arrBuffer) {
      const byteArray = [];
      for (let i = 0; i &lt; 4; i++) {
          byteArray.push(arrayBuffer[i]);
      }
      let headerContent = '';
  
      // Create the headerContent
      for (let i = 0; i &lt; byteArray.length; i++) {
          headerContent += byteArray[i].toString(16);
      }
      // Uncaught TypeError: Cannot read property 'toString' of undefined
  
  }
  </code></pre>