One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
tfrysinger
4 years agoExplorer | Level 4
How can I Iist files after a designated create date using Node.js SDK?
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!
- 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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,947 PostsLatest Activity: 4 hours ago
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 or Facebook.
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!