Created
February 27, 2018 13:18
-
-
Save muthuspark/f43b08251cd0ec813dfd75823a644fff to your computer and use it in GitHub Desktop.
List all the files in AWS bucket nodejs
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
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