fix progress, fail without file object

This commit is contained in:
j 2016-08-30 18:56:11 +02:00
parent cf3161d4bd
commit e086a93c9c

View file

@ -37,6 +37,10 @@ pandora.chunkupload = function(options) {
request, request,
that = Ox.Element(); that = Ox.Element();
if (Ox.typeOf(file) != 'file') {
Ox.print('Invalid arguments, options.file must be file', options);
return;
}
options.data = options.data || {}; options.data = options.data || {};
initUpload(); initUpload();
@ -134,9 +138,10 @@ pandora.chunkupload = function(options) {
} else { } else {
that.status = Ox._('Sorry, your browser is currently not supported.'); that.status = Ox._('Sorry, your browser is currently not supported.');
done(); done();
return;
} }
progress(Math.min(parseFloat(chunkOffset)/bytesAvailable), 1); progress(Math.min(parseFloat(chunkOffset) / bytesAvailable, 1));
request = new XMLHttpRequest(); request = new XMLHttpRequest();
request.addEventListener('load', function (evt) { request.addEventListener('load', function (evt) {
@ -211,7 +216,7 @@ pandora.chunkupload = function(options) {
}, false); }, false);
request.upload.addEventListener('progress', function (evt) { request.upload.addEventListener('progress', function (evt) {
if (evt.lengthComputable) { if (evt.lengthComputable) {
progress(parseFloat(chunkOffset + evt.loaded) / bytesAvailable); progress(Math.min(parseFloat(chunkOffset + evt.loaded) / bytesAvailable, 1));
} }
}, false); }, false);
request.addEventListener('abort', function (evt) { request.addEventListener('abort', function (evt) {