title: What function should I choose to make base64-string from a File object?
body: <p>I have File object (audio which I got by <code>&lt;input type=file</code> />). </p>
  
  <p>I want to send it on the server to save in storage. </p>
  
  <p>I will send json that containt base64-string which I want to get from the file object.</p>
  
  <p>I 'm confused about what function of <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader" rel="nofollow noreferrer">fileReader interface</a> should I choose to convert file in base64. 
  Now I use <code>readAsBinaryString</code>:</p>
  
  <pre><code>function getBase64(file) {
    return new Promise ( (res,rej) =&gt; {
      var reader = new FileReader();
      reader.readAsBinaryString(file);
      reader.onload = function () {
        res(reader.result);
      };
    })
  }
  </code></pre>
  
  <p>With this method I save audio-file to server, after I download it and change extension like was before (mp3 in my case) and the audio isn't playing. I see an error about codecs.</p>
  
  <p>Maybe I missed something important in my chain of action, i don't know.
  Thank you in advance.</p>