fetch array buffers in cryptpad-common

pull/1/head
ansuz 8 years ago
parent 56a871cb67
commit df47b913e3

@ -89,5 +89,15 @@ define([], function () {
return Math.floor(bytes / 1024 * 100) / 100;
};
Util.fetch = function (src, cb) {
var xhr = new XMLHttpRequest();
xhr.open("GET", src, true);
xhr.responseType = "arraybuffer";
xhr.onload = function () {
return void cb(void 0, new Uint8Array(xhr.response));
};
xhr.send(null);
};
return Util;
});

@ -66,6 +66,7 @@ define([
common.fixFileName = Util.fixFileName;
common.bytesToMegabytes = Util.bytesToMegabytes;
common.bytesToKilobytes = Util.bytesToKilobytes;
common.fetch = Util.fetch;
// import hash utilities for export
var createRandomHash = common.createRandomHash = Hash.createRandomHash;

Loading…
Cancel
Save