cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

filesListFolder slow

filesListFolder slow

filipengstrom91
Explorer | Level 3

Hi, 

I use the Dropbox webhook to start a Javascript function I've written. It worked great the first few months when the folders just contained a few files. Now they contain approximately 200-250 files and it takes approximately 30 seconds to fetch all the files with filesListFolder function. This amount of time surely can't be normal, I want to be able to use it as my folders grows with files. The following lines of code are where I figure the problem is:

 
const fetch = require('isomorphic-fetch'); // or another library of choice.
const Dropbox = require("dropbox").Dropbox;
const dbx = new Dropbox({ accessToken: 'T-BxAk********************************************Cn2eeFT', fetch: fetch });
const response = await dbx.filesListFolder({ path: "/Redovisning/", recursive: true, limit: 5 })
let cursor = response.cursor;
let hasMore = response.has_more;

const entriesArray = [response.entries];

while (hasMore === true) {
let responseWhile = await dbx.filesListFolderContinue({ cursor: cursor });
hasMore = responseWhile.has_more;
cursor = responseWhile.cursor;
for (entry of responseWhile.entries) {
entriesArray.push(entry);
}
}
console.log(entriesArray);
Thanks
1 Accepted Solution

Accepted Solutions

Re: filesListFolder slow

Greg-DB
Dropboxer

There are a number of variables that can affect the overall performance here, so we can't promise any specific speed for listing a folder. Looking at your code though, there are a few things that may help:

  • You're using "limit: 5", which will limit Dropbox to returning about 5 entries per page. Since you need to make an HTTP request and response for each page, using a small limit like that will increase the overhead and increase how long the entire process takes. If you don't need to use a small page size like that for some reason, switching to a larger number may speed this up.
  • You're using "recursive: true", which can increase how much work Dropbox has to do to list out the entries. If you don't need nested entries, switching this to "recursive: false" may speed this up.

View solution in original post

2 Replies 2

Re: filesListFolder slow

Greg-DB
Dropboxer

There are a number of variables that can affect the overall performance here, so we can't promise any specific speed for listing a folder. Looking at your code though, there are a few things that may help:

  • You're using "limit: 5", which will limit Dropbox to returning about 5 entries per page. Since you need to make an HTTP request and response for each page, using a small limit like that will increase the overhead and increase how long the entire process takes. If you don't need to use a small page size like that for some reason, switching to a larger number may speed this up.
  • You're using "recursive: true", which can increase how much work Dropbox has to do to list out the entries. If you don't need nested entries, switching this to "recursive: false" may speed this up.

View solution in original post

Re: filesListFolder slow

filipengstrom91
Explorer | Level 3

Thank you for your reply. Changing the limit to 2000 solved my problem. It now loads within a couple of seconds. I realise that I didn't understand what limit meant. Thanks!

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    filipengstrom91 Explorer | Level 3
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?