Updated on 2023-03-16 GMT+08:00

Listing Objects

If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see the API Reference.

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.