cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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: 

too_many_requests when uploading multiple files

too_many_requests when uploading multiple files

Beatso
Explorer | Level 4

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 7

Greg-DB
Dropbox Staff

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
Explorer | Level 4

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
Dropbox Staff

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
Explorer | Level 4

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
Dropbox Staff

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
New member | Level 2

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
Dropbox Staff

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

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Siva K New member | Level 2
  • User avatar
    Beatso Explorer | Level 4
What do Dropbox user levels mean?