Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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
}
}]
})
})();
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.
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.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
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!