Download a file from the drive using the context menu

This commit is contained in:
yflory
2018-11-06 18:35:04 +01:00
parent dcdc0972dd
commit a5b04bd62a
7 changed files with 193 additions and 33 deletions

View File

@@ -138,11 +138,19 @@ define([], function () {
};
// given a path, asynchronously return an arraybuffer
Util.fetch = function (src, cb) {
Util.fetch = function (src, cb, progress) {
var CB = Util.once(cb);
var xhr = new XMLHttpRequest();
xhr.open("GET", src, true);
if (progress) {
xhr.addEventListener("progress", function (evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
progress(percentComplete);
}
}, false);
}
xhr.responseType = "arraybuffer";
xhr.onerror = function (err) { CB(err); };
xhr.onload = function () {