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.

Uploading multiple files to multiple endpoints

See original GitHub issue

I have not yet found a way to use the XHRUpload plugin with multiple files where each file has it’s own endpoint. The docs say that endpoint can only be one string. I understand that I could create multiple instances, but is that the way to go?

What I want to do is add an array of files and specify the endpoint for each. Is this possible?

Issue Analytics

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

github_iconTop GitHub Comments

14reactions
goto-bus-stopcommented, Feb 3, 2020

Thanks for that example. We should provide an official API for it. At the moment, you can do something like the below.

The XHRUpload plugin reads option overrides from the file.xhrUpload property if it exists. This is not documented but is not going to be removed in a non-major release because we depend on it in the S3 plugin.

const file = uppy.getFile(fileID)
uppy.setFileState(fileID, {
  xhrUpload: {
    ...file.xhrUpload,
    endpoint: `https://endpoint/?filename=${encodeURIComponent(file.meta.name)}`
  }
})

You could do this for each file as it is added in an uppy.on('file-added') event listener, or do it just before an upload starts using uppy.on('upload', () => {}) and loop through all files uppy.getFiles().

1reaction
marxjbcommented, Oct 21, 2019

Hey @arturi , sorry for the delayed reply.

We have data which, logically, belongs together and a failed upload in either part is considered to be a failure state. We are generating upload urls for each particular upload beforehand, but we want to handle all uploads “as one”, that means, if one fails, it should retry, we want to use the automatic timeouts etc.

As it stands, we cannot use any of the “advanced” features of uppy because we can only upload one file to one url. We have written some business logic beforehand to handle it and were hoping to get rid of it by using uppy.

Creating multiple instances yields the same problem, it won’t handle retries etc and/or we would have to glue the logic of multiple instances together (retry if one failed, max num of uploads etc)

Does that make it clearer/help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

multiple end points for uploading files to multiple locations
What I am trying to achieve is if a user drops multiple files to a drop area and based on the files types,...
Read more >
Uploading Multiple Files with Angular and .NET Web API
In order to make the API endpoint accept multiple files, we simply need to program the action method to take an input parameter...
Read more >
How to upload multiple files in Java Spring Boot - BezKoder
Spring Boot upload Multiple Files with Postman​​ – Upload some files: In the Body tab, chose form-data, key files as File type. For...
Read more >
Handling multiple endpoints? - Tus - Transloadit Community
Run multiple tus servers at different endpoints which store the uploads on different locations. This is easy to setup but can be though...
Read more >
Uploading Multiple Files with Fetch - YouTube
This video is the sequel to the File and Filelist video and explains how to use fetch( ) to upload a single file...
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