committed by
Julius Härtl
parent
2eca9c2d01
commit
6cab67cb11
@@ -39,7 +39,11 @@ export default {
|
||||
bodyFormData.append('type', 'deck_file')
|
||||
bodyFormData.append('file', file)
|
||||
try {
|
||||
await this.$store.dispatch('createAttachment', { cardId: this.cardId, formData: bodyFormData })
|
||||
await this.$store.dispatch('createAttachment', { cardId: this.cardId,
|
||||
formData: bodyFormData,
|
||||
onUploadProgress: (e) => {
|
||||
console.log(e)
|
||||
} })
|
||||
} catch (err) {
|
||||
if (err.response.data.status === 409) {
|
||||
this.overwriteAttachment = err.response.data.data
|
||||
|
||||
@@ -37,11 +37,20 @@ export class AttachmentApi {
|
||||
return response.data
|
||||
}
|
||||
|
||||
async createAttachment({ cardId, formData }) {
|
||||
async createAttachment({ cardId, formData, onUploadProgress }) {
|
||||
const config = {
|
||||
onUploadProgress: function(progressEvent) {
|
||||
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
||||
console.log(percentCompleted)
|
||||
},
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: this.url(`/cards/${cardId}/attachment`),
|
||||
data: formData,
|
||||
...config,
|
||||
onUploadProgress,
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user