Rohit Rohit - 8 months ago 141
Node.js Question

AWS S3 object listing

I am using aws-sdk using node.js. I want to list images in specified folder e.g.This is the directory that i want to fetch

I want to list all files and folder in this location but not folder (images) content. There is list Object function in aws-sdk but it is listing all the nested files also.

Here is the code :

var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: 'mykey', secretAccessKey: 'mysecret', region: 'myregion'});
var s3 = new AWS.S3();

var params = {
Bucket: '',
Delimiter: '',
Prefix: 's/5469b2f5b4292d22522e84e0/ms.files'

s3.listObjects(params, function (err, data) {
if(err)throw err;


Folders are illusory, but S3 does provide a mechanism to emulate their existence.

If you set Delimiter to / then each tier of responses will also return a CommonPrefixes array of the next tier of "folders," which you'll append to the prefix from this request, to retrieve the next tier.

If your Prefix is a "folder," append a trailing slash. Otherwise, you'll make an unnecessary request, because the first request will return one common prefix. E.g., folder "foo" will return one common prefix "foo/".