Updated on 2026-01-16 GMT+08:00

Listing Objects

After objects are uploaded, you may want to view the objects contained in a bucket. Sample code is as follows:

obsClient.listObjects({
       Bucket : 'bucketname'
}, function (err, result) {
       if(err){
              console.error('Error-->' + err);
       }else{
              console.log('Status-->' + result.CommonMsg.Status);
              if(result.CommonMsg.Status < 300 && result.InterfaceResult){
                     for(var j in result.InterfaceResult.Contents){
                           console.log('Contents[' + j +  ']:');
                           console.log('Key-->' + result.InterfaceResult.Contents[j]['Key']);
                           console.log('LastModified-->' + result.InterfaceResult.Contents[j]['LastModified']);
                           console.log('Size-->' + result.InterfaceResult.Contents[j]['Size']);
                     }
              }
       }
});
  • In the previous sample code, 1000 objects will be listed, by default.
  • For more information, see Listing Objects.