fix(Gallery): send substring to API when it's a video
This commit is contained in:
parent
20adf407f0
commit
2020e79cab
1 changed files with 10 additions and 2 deletions
|
@ -262,7 +262,11 @@ export default {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.readAsArrayBuffer(file)
|
reader.readAsArrayBuffer(file)
|
||||||
reader.onloadend = (event) => {
|
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 = () => {
|
reader.onerror = () => {
|
||||||
console.log(reader.error)
|
console.log(reader.error)
|
||||||
|
@ -275,7 +279,11 @@ export default {
|
||||||
const promises = this.files.map(file => this.loadFile(file))
|
const promises = this.files.map(file => this.loadFile(file))
|
||||||
Promise.all(promises).then(results => {
|
Promise.all(promises).then(results => {
|
||||||
const formData = new FormData()
|
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, {
|
this.$apitator.post('/delegate/medias', formData, {
|
||||||
withAuth: true,
|
withAuth: true,
|
||||||
|
|
Loading…
Reference in a new issue