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!