• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Python 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:

resp = obsClient.listObjects('bucketname')
if resp.status < 300:    
    print('requestId:', resp.requestId)
    index = 0
    for content in resp.body.contents:
        print('content [' + str(index) + ']')
        print('key:', content.key)
        print('lastModified:', content.lastModified)
        print('size:', content.size)
        index += 1
else:    
    print('errorCode:', resp.errorCode)
    print('errorMessage:', resp.errorMessage)
NOTE:
  • In the previous sample code, 1000 objects will be listed, by default.
  • For more information, see Listing Objects.