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