Skip to content

Instantly share code, notes, and snippets.

@nicokruger
Created March 13, 2020 11:00
Show Gist options
  • Save nicokruger/d9c986e41a606586bc411a01be97ac53 to your computer and use it in GitHub Desktop.
Save nicokruger/d9c986e41a606586bc411a01be97ac53 to your computer and use it in GitHub Desktop.
getAllS3Objects
async function getAllS3Objects(Params) {
let listing = true;
const objects = [];
while (listing) {
const data = await s3.listObjects(Params).promise();
if (!data.isTruncated) {
listing = false;
} else {
Params.Marker = data.NextMarker;
}
objects.push(...data.Contents);
}
console.log('got objects', objects);
const a = _.sortBy(objects, (x) => {
return x.LastModified;
});
a.reverse();
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment