vue-upload-component
vue-upload-component copied to clipboard
post-action prop doesn't handles changes
If I need to change the post-action
between the time the vue-upload
is created, and the time that the upload is ran, the component doesn't handle changes to that prop...
I'm using a computed property that changes the endpoint as needed, yet the component only uses it's initial value.
I have the same issue, there is no possibility to change or modify post-action.
Anyone able to get around this?
Hi, I just ran in the same issue but I found a solution and wanted to let all the other people know...
My problem was that I firstly needed to create a root entity to which the files need to be attached to. So I need that just created ID within the post method.
I simply add the files, create my own entity and after that update the files using the update method.
Sample code: (pseudo code)
methods: {
onDrop(e) {
// add files purposely with invalid postAction
this.$refs.upload.addDataTransfer(e.dataTransfer);
// create new entity and get its id.
const entityId = await createNewEntity(...);
// update existing files and new post action.
this.files.forEach((file) => {
this.$refs.upload.update(file, {postAction: this.postAction});
})
},
},
computed: {
postAction: {
return `someurl/${someID}/attachments`
}
}