I have written a code to fetch a file name from s3 that only gives a single file, for example I have a file's names as 01-data-dict-2021-04-01.gz, 02-data-dict-2021-04-01.gz and so on but my code print only 01-data-dict-2021-04-01.gz
This my code
let items = [];
const listS3Objects = (marker) => {
s3.listObjects({
Bucket: 'JobPoy',
Prefix: 'datacenter/01-data-dict-2021-04-01.gz',
Marker: marker
}, (err, s3Items) => {
if (err) {
console.log(err);
process.exit();
}
s3Items.Contents.forEach(i => items.push(i.Key));
if (s3Items.Contents.length === 1000) {
console.log(`Fetching more files ${s3Items.Contents[999].Key}`);
listS3Objects(s3Items.Contents[999].Key)
} else {
console.log("====>",items)
}
});
};
the output of items is [01-data-dict-2021-04-01.gz] but I want to get [01-data-dict-2021-04-01.gz, 02-data-dict-2021-04-01.gz and so on........]