Question

I'm trying to use filepicker.io to fetch binary data and pass it into a function like this:

var doSomething = function(arrayBuffer) {
    var u16 = new Int16Array(arrayBuffer);
}

I have no idea how to convert the binary into arraybuffer like this:

filepicker.getContents(url, function(data){
//convert data into arraybuffer
}

I tried to follow this tutorial on XMLHttpRequest but does't not work.

var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
    doSomething(this.response); 
};
Was it helpful?

Solution

You are not calling .send with your XHR

xhr.send(null);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top