From 2020e79cabf5057c0500e6e8c4c91fce64f97647 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Wed, 2 Sep 2020 22:58:57 +0200 Subject: [PATCH] fix(Gallery): send substring to API when it's a video --- src/views/Delegate/Gallery.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/views/Delegate/Gallery.vue b/src/views/Delegate/Gallery.vue index 4d7c956..e0ce671 100644 --- a/src/views/Delegate/Gallery.vue +++ b/src/views/Delegate/Gallery.vue @@ -262,7 +262,11 @@ export default { const reader = new FileReader() reader.readAsArrayBuffer(file) reader.onloadend = (event) => { - resolve(['file', event.target.result, file.name]) + let name = file.name + if (file.type.indexOf('video') !== -1) { + name += '||%_FORMAT_VIDEO_%||' // it's a dirty way to say to the back end : 'hey this is a video file !' + } + resolve(['file', event.target.result, name]) } reader.onerror = () => { console.log(reader.error) @@ -275,7 +279,11 @@ export default { const promises = this.files.map(file => this.loadFile(file)) Promise.all(promises).then(results => { const formData = new FormData() - results.forEach(r => formData.append(r[0], new Blob([new Uint8Array(r[1])]), r[2])) + results.forEach(r => formData.append( + r[0], // field name + new Blob([new Uint8Array(r[1])]), // the file + r[2] // file name + )) this.$apitator.post('/delegate/medias', formData, { withAuth: true,