I have File object (audio which I got by <input type=file
/>).
I want to send it on the server to save in storage.
I will send json that containt base64-string which I want to get from the file object.
I 'm confused about what function of fileReader interface should I choose to convert file in base64.
Now I use readAsBinaryString
:
function getBase64(file) {
return new Promise ( (res,rej) => {
var reader = new FileReader();
reader.readAsBinaryString(file);
reader.onload = function () {
res(reader.result);
};
})
}
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.
Maybe I missed something important in my chain of action, i don't know. Thank you in advance.