Skip to content

Instantly share code, notes, and snippets.

@muthuspark
Created February 27, 2018 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muthuspark/f43b08251cd0ec813dfd75823a644fff to your computer and use it in GitHub Desktop.
Save muthuspark/f43b08251cd0ec813dfd75823a644fff to your computer and use it in GitHub Desktop.
List all the files in AWS bucket nodejs
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: "ACCESS_KEY",
secretAccessKey: "SECRET_ACCESS_KEY"
});
// Create an S3 client
var s3 = new AWS.S3();
// Create a bucket and upload something into it
var bucketName = 'BUCKET_NAME';
var S3Url = "https://s3-us-west-2.amazonaws.com/BUCKET_NAME/";
var params = {
Bucket: bucketName,
Delimiter: '/'
}
s3.listObjects(params, function (err, data) {
if(err)throw err;
data.Contents.forEach(function(k){
console.log(k.Key);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment