Skip to content Skip to sidebar Skip to footer

I Was Trying To Upload A Video

How to convert a Blob into a byte array? I was trying to upload a video and call to API in byte array format After doing the below code, we getting the video in 'blob:http://localh

Solution 1:

You need to use FileReader to get the contents of the file into a ArrayBuffer which you can then use a TypedArray of your choice.

var fr = new FileReader();
fr.onloadend = function(){
  //fr.result will be an ArrayBuffer so create an Int8Array view
  var data = new Int8Array(fr.result);
  //use data as you wish.
};
fr.readFileAsArrayBuffer(file.files[0]);

Post a Comment for "I Was Trying To Upload A Video"