The title says it all. How can I abort the upload with UIKits Upload Component?
I'm trying to abort the upload in the beforeAll
callback but I can't seem to get it to work.
UIkit.upload('.js-upload', {
url: '',
multiple: false,
mime: 'audio/*',
allow: '*.mp3',
beforeAll: function () {
return false; // <--- Why does it not return/abort?
});
}
});
Have a look at the source code. The return value from beforeAll
isn't used.
The best option I see to abort the request is to get hang of the XMLHttpRequest
object and call abort()
on it:
UIkit.upload(".js-upload", {
// ...
loadStart: function (e) {
e.target.abort();
},
abort: function (e) {
// clean up after abort
}
// ...
});