Created
February 20, 2019 19:01
-
-
Save graciano/862dea796080ea3216f16dd09aae21bd to your computer and use it in GitHub Desktop.
list files from given folder in s3
This file contains hidden or 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
const { S3 } = require('aws-sdk'); | |
const { promisify } = require('util'); | |
const main = async () => { | |
const s3 = new S3(); | |
const s3ListPromise = async params => promisify(s3.listObjectsV2).bind(s3)(params); | |
const listObjects = async (Bucket, Prefix) => s3ListPromise({ | |
Bucket, | |
Prefix, | |
}); | |
const bucket = 'mybucket'; | |
const dir = 'desired/path/'; | |
try { | |
const objects = await listObjects(bucket, dir); | |
console.log('objects', objects); | |
} catch (err) { | |
console.log(err); | |
} | |
}; | |
main().then(res => console.log('bye', res) && process.exit()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment