NoelOConnell/quill-image-uploader

How to cancel upload if image is oversize?

mu-yu opened this issue · 2 comments

mu-yu commented

I have tried to reject the promise, but it still upload the picture with base64 string.

mu-yu commented

I have debuged the code of this plugin, and found that filereader load event is happened after removeBase64Image function in error handler.

fileReader.addEventListener(
'load',
() => {
let base64ImageSrc = fileReader.result;
this.insertBase64Image(base64ImageSrc);
},
false
);

error => {
this.removeBase64Image();
console.warn(error);
}

if the uploader rejected before load happened, the placeholder won't deleted any more.
This usually happened when i wan't to reject uploader after check filesize.

This is same with issue #6 .

PR merged now.

Version 1.1.1 is released on NPM now with those changes.

👍