title: Read file slice as bytes and send to server?
body: <p>I want to read a slice of a file using a FileReader, and then send it to a server. This is what I have so far:</p>
  
  <pre><code>const createReader = onRead =&gt; {
    const reader = new FileReader();
    reader.onloadend = function(evt) {
      if (evt.target.readyState === FileReader.DONE) {
        const arrayBuffer = evt.target.result;
        const bytes = new Uint8Array(arrayBuffer);
        console.log("BYTES: ", bytes);
        onRead(evt.target.result);
      }
    };
    return reader;
  };
  
  const reader = createReader(fileSlice =&gt; {
    console.log("BYTES: ", fileSlice);
    // send to server
  });
  reader.readAsArrayBuffer(blob);
  </code></pre>
  
  <p>Here's what it printed when I uploaded a simple .txt file:</p>
  
  <p>However, it returns an array, and I'm not sure how to convert this into a format that I can send over to my server through HTTP.</p>
  
  <p><a href="https://i.stack.imgur.com/98PSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/98PSc.png" alt="enter image description here"></a></p>
  
  <p>Does anyone know what I need to do in order to convert that byte array into a format that I can eventually turn back into the original file?</p>