vue-upload-component icon indicating copy to clipboard operation
vue-upload-component copied to clipboard

post-action prop doesn't handles changes

Open douglasg14b opened this issue 5 years ago • 3 comments

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.

douglasg14b avatar Sep 05 '19 20:09 douglasg14b

I have the same issue, there is no possibility to change or modify post-action.

umatik avatar Oct 09 '19 09:10 umatik

Anyone able to get around this?

jcroucher avatar Jun 28 '22 12:06 jcroucher

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`
    } 
}

julianhirt avatar Mar 09 '23 10:03 julianhirt