Display proper file upload errors

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-25 17:54:28 +02:00
parent 63ac985f15
commit b4ead5a2eb
3 changed files with 19 additions and 10 deletions

View File

@@ -30,13 +30,17 @@ export default class FileService {
this.cardservice = CardService;
this.uploader.onAfterAddingFile = this.onAfterAddingFile.bind(this);
this.uploader.onSuccessItem = this.onSuccessItem.bind(this);
this.uploader.onErrorItem = this.onErrorItem.bind(this);
this.status = null;
}
runUpload (fileItem, attachmentId) {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment');
this.status = null;
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment?type=deck_file');
if (typeof attachmentId !== 'undefined') {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId);
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId + '?type=deck_file');
} else {
fileItem.formData = [
{
@@ -95,6 +99,13 @@ export default class FileService {
this.cardservice.get(item.cardId).attachments.push(response);
}
onErrorItem (item, response) {
this.status = {
error: t('deck', `Failed to upload:`) + ' ' + item.file.name,
message: response.message
};
}
}
app.service('FileService', FileService);