I am using aws-sdk using node.js. I want to list images in specified folder e.g.
As mentioned in the comments, S3 doesn't "know" about folders, only keys. You can imitate a folder structure with / in the keys. See here for more information - http://docs.aws.amazon.com/AmazonS3/latest/UG/FolderOperations.html
That said, you can modify your code to something like this:
s3.listObjects(params, function (err, data) {
if(err) throw
//data.contents is an array of objects according to the s3 docs
//iterate over it and see if the key contains a / - if not, it's a file (not a folder)
var itemsThatAreNotFolders = data.contents.map(function(content){
if(content.key.indexOf('/')<0) //if / is not in the key
return content;
});
console.log(itemsThatAreNotFolders);
});
This will check each key to see if it contains a /