• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Objects-Related APIs
  5. List Parts

List Parts

API Description

You can use this API to list the uploaded parts in a bucket by using the multipart upload ID.

Method Definition

ObsClient.listParts(bucketName, objectKey, uploadId, maxParts, partNumberMarker)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

uploadId

str

Mandatory

Multipart upload ID

maxParts

int

Optional

Maximum number of uploaded parts that can be listed per page

partNumberMarker

int

Optional

Part number after which listing uploaded parts begins. Only parts whose part numbers are larger than this value will be listed.

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

ListPartsResponse

Response result of List Parts

Sample Code

try:
    resp = obsClient.listParts('bucketname', 'objectkey', 'uploadid', 10) 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('bucketName:', resp.body.bucketName) 
        print('objectKey:', resp.body.objectKey) 
        print('uploadId:', resp.body.uploadId) 
        print('storageClass:', resp.body.storageClass) 
        print('isTruncated:', resp.body.isTruncated) 
        print('initiator:', resp.body.initiator) 
        print('owner:', resp.body.owner) 
         
        index = 1 
        for part in resp.body.parts: 
            print('part [' + str(index) + ']') 
            print('partNumber:', part.partNumber) 
            print('lastModified:', part.lastModified) 
            print('etag:', part.etag) 
            print('size:', part.size) 
            index += 1 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())