• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Node.js SDK)
  4. Quick Start
  5. Listing Objects

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'
}, (err, result) => {
       if(err){
              console.error('Error-->' + err);
       }else{
              console.log('Status-->' + result.CommonMsg.Status);
              if(result.CommonMsg.Status < 300 && result.InterfaceResult){
                     for(let i=0;i<result.InterfaceResult.Contents.length;i++){
                           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']);
                     }
              }
       }
});
NOTE:
  • In the sample code, 1000 objects will be listed, by default.
  • For more information, see Listing Objects.