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.