I'm new to GCS. I'm trying to list the files in a "folder" & download them, however my list is return the folder name as index 0.
How do I only list the files name and not the name of the directory? Or should I just shift() the array after I get the list back?
const prefix = 'testFiles/'; //contains jpgs
const delimiter = '/';
const options = {
prefix: prefix,
};
if (delimiter) {
options.delimiter = delimiter;
}
const [files] = await storage.bucket(bucketName).getFiles();
files.forEach((file, i) => {
options.destination = `./downloads/${i}.jpg`
console.log(options);
file.download(options)
});
}