Hello All!
I am using Dropbox Javascript SDK to manage my files within Dropbox. I have come across a scenario where I need to copy 1 or many files (depends) into a single folder.
For this, I am using the filesCopyV2 api and proving different paths as the source, but the destination would be the same. Here's the sample code which I have tried in Node JS.
const randomNum = makeRandomId(10);
const filePaths = [];
files.forEach(file => filePaths.push({ from_path: '/Source/' + file, to_path: '/Destination/' + randomNum }));
const result = await dbx.filesCopyBatchV2({ entries: filePaths, autorename: false });
console.log(result);
Now when I execute this piece of code, it works fine for the first file only. Starting from the next file, I am getting a relocation error. The response is shown below:
{
".tag": "complete",
"entries": [
{
".tag": "success",
"success": {
".tag": "folder",
"name": "KQMcvsrofA",
"path_lower": "/destination/kqmcvsrofa",
"path_display": "/Destination/KQMcvsrofA",
"id": "id:BhIiassdeAAALg"
}
},
{
".tag": "failure",
"failure": {
".tag": "relocation_error",
"relocation_error": {
".tag": "to",
"to": {
".tag": "conflict",
"conflict": {
".tag": "folder"
}
}
}
}
}
]
}For instance, if I were to copy 2 files, the first file is copied and the second file is not.
How can I solve this issue? I hope I am using the correct API provided by official Dropbox Team but please correct me if I am wrong.
Thank you