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