Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
zainulabd786
7 years agoExplorer | Level 3
How to upload multiple files using JavaScript SDK?
Hi, I am using Javascript SDK to upload multiple files at once. I have a dropbox business account enabled and the folder where I am trying to upload the files is a shared folder.
I want to upload t...
- 7 years ago
I see, thanks for clarifying. The Dropbox API doesn't offer a way to upload multiple files in one call, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.
That being the case, you will need to loop through your files and call filesUpload once per file. Apologies I don't have better news for you!
zainulabd786
7 years agoExplorer | Level 3
I am having a problem when I am trying to Loop through the files array. Here's my code
const files = req.files
const clientFolder = req.client_folder
const { dbxUser } = req;
const promises = []
for(const file of files){
let args = {
contents: file.buffer,
path: `${clientFolder}/${file.originalname}`,
mode: 'add',
autorename: true,
mute: false,
strict_conflict: false
}
promises.push(dbxUser.filesUpload(args))
}
Promise.all(promises).then(i => {
console.log(i)
res.status(200).json({message: "Uploaded", status: i});
})dbxUser.filesUpload(args) is an asynchronous function. So I am wondering How can I use this inside the loop.
In my above code I am expecting the function to store the promises in the array, But the promises array is blank in this case
zainulabd786
7 years agoExplorer | Level 3
Sorry! it was a typo in my react application because of which files were empty. The issue got resolved.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!