I am using the nodeJS google storage module to get files from a bucket, but the bucket contains loads of files and folders so it is taking a very long time to return , any suggestion on how to make it faster? or more stream line?
this is my code
export const getFiles = async () => {
const BUCKET_NAME = 'archive';
const bucket = new Storage({credentials: creds}).bucket(BUCKET_NAME);
const [ bucketFiles ] = await bucket.getFiles({autoPaginate: false});
console.log(bucketFiles)
return bucket
.getFiles()
.then(([files]) => {
const filesResponse = files.map(({ metadata: file }) => ({
cacheControl: file.cacheControl || "",
contentEncoding: file.contentEncoding || "",
contentType: file.contentType || "",
version: file.generation,
id: file.id,
downloadLink: file.mediaLink,
path: file.name,
size: file.size,
updated: file.updated,
originalFileName: file.originalFileName,
}));
console.log ({ bucket: bucket.name, files: filesResponse });
return ({ bucket: bucket.name, files: filesResponse });
})
.catch();
};