Last active
April 25, 2018 20:51
-
-
Save slaughtr/e5a2f543afd971184edad664ee65c282 to your computer and use it in GitHub Desktop.
Helpful async/await for AWS
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
// get a JSON file from S3 and immediately parse the JSON to a JS object | |
const testObj = JSON.parse(await s3.getObject({ Bucket: 'test', Key: test }).promise().then(res => res.Body.toString())); | |
// get all keys from an S3 listObjectV2 as an array (assuming no pagination of results) | |
const keysArr = (await s3.listObjectsV2({Bucket: 'test', Prefix: 'test'}).promise().then(res => res.Contents)).map(item => item.Key); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment