We’re aware of an issue causing slower load times on the Dropbox Community forum. It should be resolved soon. Thanks for your patience!
Forum Discussion
Tigerseo
4 years agoExplorer | Level 3
filesUploadSessionFinishBatchV2: Response failed with a 413 code
Hello!
I am trying to upload 10~20 image files at once to Dropbox professional account with Javascript SDK.
Each image is less than 15MB.
According to DBX Performance guide, I tried to upload 1 image with batch function like below.
file1 = "./public/demo/1.png";
file2 = "./public/demo/2.jpg";
data1 = fs.readFileSync(file1);
data2 = fs.readFileSync(file2);
tpath1 = "/demo/data12.png";
tpath2 = "/demo/data2.jpg";
function startBatch() {
return new Promise(resolve=> {
r = dbx.filesUploadSessionStartBatch({
num_sessions: 1
});
resolve(r);
});
}
function upload(sid) {
return new Promise(resolve=> {
// r = dbx.filesUploadSessionStart({ close: true, contents: data1})
console.log("upload func:"+sid);
r = dbx.filesUploadSessionAppendV2({
contents: data1,
cursor: {
contents: data1,
session_id: sid[0],
offset: data1.length
},
close: true
});
resolve(r);
});
}
(async ()=>{
r = await startBatch();
sid = r.result.session_ids;
console.log(sid);
(async ()=>{
r1 = await upload(sid);
console.log(r1);
})();
dbx.filesUploadSessionFinishBatchV2({
entries: [{
cursor: {
session_id: sid[0],
offset: data1.length,
contents: data1
},
commit: {
path: tpath1,
mode: true,
autorename: true,
mute: false,
strict_conflict: true
}
}]
})
})();
When the program runs at filesUploadSessionFinishBatchV2, it show me 'DropboxResponseError: Response failed with a 413 code' like below
I tried to find out what the solution is, so far I don't get one.
Please note that I'm new to Javscript and ES6 : (
If you show me a code, that would be helpful.
I just want to upload 20 image files it without any error.
Help me out please.
1 Reply
- Greg-DB4 years ago
Dropbox Community Moderator
A 413 error indicates that the request failed because the payload was too large.
The filesUploadSessionFinishBatchV2 method in particular is a way to finish multiple upload sessions at once, and does not itself accept file data. That being the case, don't set 'contents' when calling filesUploadSessionFinishBatchV2.
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!