Add a timeout for file upload if we can't make a thumbnail

pull/1/head
yflory 5 years ago
parent 5e8fc41b06
commit 96fcc852d6

@ -197,6 +197,13 @@ define([
};
Thumb.fromBlob = function (blob, _cb) {
var cb = Util.once(_cb);
// The blob is already in memory, it should be super-fast to make a thumbnail
// ==> 1s timeout
setTimeout(function () {
console.error("Thumbnail timeout");
cb('TIMEOUT');
}, 1000);
try {
if (blob.type.indexOf('video/') !== -1) {
return void Thumb.fromVideoBlob(blob, cb);
}
@ -209,6 +216,9 @@ define([
if (blob.type.indexOf('image/') !== -1) {
return void Thumb.fromImageBlob(blob, cb);
}
} catch (e) {
return void cb('THUMBNAIL_ERROR');
}
return void cb('NO_THUMBNAIL');
};

Loading…
Cancel
Save