node.jsamazon-s3knox-amazon-s3-client

How to list files in amazon s3 bucket with in the folder using knox and nodejs


I want to list file in my s3 bucket with in the folder, my bucket structure is

         /> folder_1
a_bucket -> folder_2
         \> folder_3

I want list files in folder_1 only


Solution

  • My problem got solved

    s3client.list({ "prefix": "folder_1/" + filePrefix }, function (err, data) {
    /* `data` will look roughly like:
    
      {
        Prefix: 'my-prefix',
        IsTruncated: true,
        MaxKeys: 1000,
        Contents: [
          {
            Key: 'whatever'
            LastModified: new Date(2012, 11, 25, 0, 0, 0),
            ETag: 'whatever',
            Size: 123,
            Owner: 'you',
            StorageClass: 'whatever'
          },
          ⋮
        ]
      }
    
      */
    }