[new feature] Uploader: before-read support promise mode (#3572)

This commit is contained in:
neverland
2019-06-20 16:14:07 +08:00
committed by GitHub
parent 12f1939e7d
commit 729b9dac4b
6 changed files with 159 additions and 8 deletions

View File

@@ -59,11 +59,29 @@ export default sfc({
files = files.length === 1 ? files[0] : [].slice.call(files);
if (this.beforeRead && !this.beforeRead(files, this.detail)) {
this.resetInput();
return;
if (this.beforeRead) {
const response = this.beforeRead(files, this.detail);
if (!response) {
this.resetInput();
return;
}
if (response.then) {
response
.then(() => {
this.readFile(files);
})
.catch(this.resetInput);
return;
}
}
this.readFile(files);
},
readFile(files) {
const oversize = isOversize(files, this.maxSize);
if (Array.isArray(files)) {