Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,36 +208,40 @@
this.$emit('upload');

if (!this.readonly) {
files = this.allowMultiple ? files : [files[0]];
files = await this.validateFiles(files);
try {
files = this.allowMultiple ? files : [files[0]];
files = await this.validateFiles(files);

// Show errors if relevant
if (this.totalUploadSize > this.availableSpace) {
this.showStorageExceededAlert = true;
return;
} else if (this.unsupportedFiles.length) {
this.showUnsupportedFilesAlert = true;
} else if (this.tooLargeFiles.length) {
this.showTooLargeFilesAlert = true;
}
return this.handleUploads(files).then(fileUploads => {
const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error);
if (fileUploads.length) {
for (const fileUpload of fileUploads) {
fileUpload.uploadPromise
.then(fileObject => {
if (isFunction(this.uploadCompleteHandler)) {
this.uploadCompleteHandler(this.getFileUpload(fileObject.id));
}
})
.catch(() => {});
}
if (isFunction(this.uploadingHandler)) {
this.uploadingHandler(this.allowMultiple ? objects : objects[0]);
}
// Show errors if relevant
if (this.totalUploadSize > this.availableSpace) {
this.showStorageExceededAlert = true;
return;
} else if (this.unsupportedFiles.length) {
this.showUnsupportedFilesAlert = true;
} else if (this.tooLargeFiles.length) {
this.showTooLargeFilesAlert = true;
}
return objects;
});
return this.handleUploads(files).then(fileUploads => {
const objects = fileUploads.map(f => f.fileObject).filter(f => !f.error);
if (fileUploads.length) {
for (const fileUpload of fileUploads) {
fileUpload.uploadPromise
.then(fileObject => {
if (isFunction(this.uploadCompleteHandler)) {
this.uploadCompleteHandler(this.getFileUpload(fileObject.id));
}
})
.catch(() => {});
}
if (isFunction(this.uploadingHandler)) {
this.uploadingHandler(this.allowMultiple ? objects : objects[0]);
}
}
return objects;
});
} finally {
this.resetFileInput();
}
}
},
handleUploads(files) {
Expand All @@ -255,6 +259,9 @@
return fileUploads.filter(Boolean);
});
},
resetFileInput() {
this.$refs.fileUpload.value = '';
},
},
$trs: {
unsupportedFilesHeader: 'Unsupported files',
Expand Down
Loading