Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

Beatso's avatar
Beatso
Explorer | Level 4
6 years ago

too_many_requests when uploading multiple files

Hello,

 

I am using the javascript sdk and using dbx.filesUpload multiple times to upload multiple files, but I am getting too many requests error. How can I upload multiple files without running in to this error? Below is my error:

{
  error: {
    error_summary: 'too_many_requests/..',
    error: { reason: [Object], retry_after: 15 }
  },
  response: Body {
    url: 'https://content.dropboxapi.com/2/files/upload',
    status: 429,
    statusText: 'Too Many Requests',
    headers: Headers { _headers: [Object] },
    ok: false,
    body: PassThrough {
      _readableState: [ReadableState],
      readable: false,
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: true,
      _transformState: [Object],
      [Symbol(kCapture)]: false
    },
    bodyUsed: true,
    size: 0,
    timeout: 0,
    _raw: [
      <Buffer 7b 22 65 72 72 6f 72 5f 73 75 6d 6d 61 72 79 22 3a 20 22 74 6f 6f 5f 6d 61 6e 79 5f 72 65 71 75 65 73 74 73 2f 2e 2e 22 2c 20 22 65 72 72 6f 72 22 3a ... 62 more bytes>
    ],
    _abort: false,
    _bytes: 112
  },
  status: 429
}

 Thanks

7 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    Attempting to upload multiple files at the same time can cause issues like this. Please refer to the Performance Guide for information on how to manage this.

  • Beatso's avatar
    Beatso
    Explorer | Level 4
    6 years ago

    Thanks for the reply. Does that mean there is no way to upload multiple (it's only 5, very small files) at once without getting caught by the ratelimit? Would I have to, for example, upload one file every second? If so, how would I do that?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    That's correct, the Dropbox API doesn't offer a way to upload multiple files in one call, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

     

    That being the case, you will need to loop through your files and call filesUpload once per file, but only call filesUpload for the next file once the previous file upload has completed, that is, once the callback method has fired.

  • Beatso's avatar
    Beatso
    Explorer | Level 4
    6 years ago

    Thanks so much for your help. How would I go about only uploading one file after the callback has completed? This is my code:

    function uploadFiles ( storageFilePaths, packFilePaths, packRoot ) {
    	for (i in storageFilePaths) {
    		dbx.filesUpload({ path: packRoot+packFilePaths[i], contents: fs.readFileSync(storageFilePaths[i]) })
    			.then(function (response) {
    				console.log(response);
    			})
    			.catch(function (err) {
    				console.log(err);
    			});
    	}
    }
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    There are a number of ways you could structure your code, but one way, much like your earlier thread, is to trigger the next operation from the previous callback method. Alternatively, you may want to look into the use of 'async' and 'await' in JavaScript.

     

  • Siva K's avatar
    Siva K
    New member | Level 2
    5 years ago

    Has the feature request mentioned here rolled out in current version? Can you kindly confirm I have a situation like I have to upload multiple files ?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    5 years ago

    Siva K No, there isn't an update on this feature request.

About Dropbox API Support & Feedback

Node avatar for 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!