Created
March 13, 2020 11:00
-
-
Save nicokruger/d9c986e41a606586bc411a01be97ac53 to your computer and use it in GitHub Desktop.
getAllS3Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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