cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

How can I Iist files after a designated create date using Node.js SDK?

How can I Iist files after a designated create date using Node.js SDK?

tfrysinger
Explorer | Level 4

I am trying to use the Node.js to query a dropbox folder from the back-end of my website, which is hosted on Wix. This folder may have thousands of files, and I want a daily routine on my website to run and delete files older than "X" days (ex: 30 days) from this folder.

 

In reviewing the APIs there does not seem to be a way to do this, other than to use the filesListFolder() API, then loop through the results and check the metadata of each individual entry to review the date and see whether or not it's created date property is later than the designated time. For example, while this works:

 

const { Dropbox } = require('dropbox');
 
// Get DB access token
let token = await getSecret("dbat");
// Get folder for items
let xferfolder = "/" + await getSecret("dbpx");
 
let dbx = new Dropbox({ accessToken: token, fetch: fetch });
// List the contents
results = await dbx.filesListFolder({path: xferfolder});
// Loop through the results, do a continue as needed, etc.
 
I get a valid set of results back, so I know my connection to Dropbox is working correctly, but given that I may have thousands, or tens of thousands of files, I need to find a better way to filter the return values. Otherwise, each month I will have to loop through every single file just to find the ones that have "expired".
 
What is the better approach?
 
Thanks!
 
1 Reply 1

Greg-DB
Dropbox Staff

Unfortunately, the Dropbox API doesn't offer a way to list/filter files only since a specific date, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

Need more support?
Who's talking

Top contributors to this post

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