question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to add reactive parameter in endpoint when uploading file on vue.js

See original GitHub issue

Hi, I want to add a dynamic/reactive parameter value which can be added as a path parameter to my endpoint when uploading the file on uppy.

uppy.use(XHRUpload, {
    endpoint: `[DYNAMIC_API_URL]/${this.textContent}`,
    formData: true,
    bundle: true,
    headers: {
      'Authorization': `Bearer ${token}`
    }
})

I do this on mounted hook. Here textContent is a reactive property that we created on Vue js. But this textContent is not being reactive property to endpoint URL that is added How can we do this?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
goto-bus-stopcommented, Jun 15, 2020

For the record, in current Uppy versions you can do:

uppy.getPlugin('XHRUpload').setOptions({
  endpoint: buildEndpointUrl()
})

Hopefully that should properly address this use case 🙏

1reaction
goto-bus-stopcommented, Sep 30, 2019

In the future, there will be an official way to do this using setOptions(): https://github.com/transloadit/uppy/pull/1728

At the moment, you can override options for XHRUpload specifically using setState():

const { xhrUpload } = uppy.getState()
uppy.setState({
  xhrUpload: {
    ...xhrUpload,
    endpoint: 'https://new-endpoint.com/'
  }
})

The object merge is important because other plugins may use the xhrUpload state to pass information to the plugin as well.

(Doing this when an upload is already in progress is not supported and will cause weird unknown breakage.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading Files With VueJS and Axios - Server Side Up
Handling files is always a task. This tutorial will simplify the process and show you how to upload files with VueJS and Axios...
Read more >
Vue File Upload with Parameters - Stack Overflow
Hi Guys i create a component to upload files and its working so far, but along with the data I'll like to pass...
Read more >
Reactivity in Depth - Vue.js
Component state consists of reactive JavaScript objects. When you modify them, the view updates.
Read more >
Intro to Vue.js. Testing on kubernetes - rf-service frontend
In this article I'm showing my first steps in Vue.js by adding simple frontend to the existing rf-service.
Read more >
[Solved]-Submit multiple files on form as part of axios post-Vue.js
You can use Base64 encode in client side and add the encoded string to your post request and decode from server side.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found