I want to achieve the functionality using cloud function in javascript - I know how to list all the files from the storage and loop through it
const ref = admin.storage().bucket();
const [result] = await ref.getFiles({ prefix: `${bucketName}/` });
But I want to list all the files based on the Time in Descending order. And after doing that I want to leave only the first 5 files and zip the remaining files in the same structure as in storage and save the zip separately in my storage