cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Musicians, convert your MuseScore files to PDF to play music on the go! Learn more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

filesUploadSessionFinishBatchV2: Response failed with a 413 code

filesUploadSessionFinishBatchV2: Response failed with a 413 code

Tigerseo
Explorer | Level 3

 

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

 

error.jpg

 

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 1

Greg-DB
Dropbox Staff

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?