Updated on 2022-02-10 GMT+08:00

List Parts

API Description

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

Method Definition

1. ObsClient->listParts(array $parameter)
2. ObsClient->listPartsAsync(array $parameter, callable $callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

string

Mandatory

Bucket name

Key

string

Mandatory

Object name

UploadId

string

Mandatory

Multipart upload ID

MaxParts

integer

Optional

Maximum number of uploaded parts that can be listed per page

PartNumberMarker

integer

Optional

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

Returned Result

Field

Type

Description

HttpStatusCode

integer

HTTP status code

Reason

string

Reason description

RequestId

string

Request ID returned by the OBS server

Bucket

string

Bucket name

Key

string

Object name

UploadId

string

Multipart upload ID

PartNumberMarker

string

Part number after which the listing uploaded parts begins, which is consistent with that set in the request

NextPartNumberMarker

string

Part number to start with upon the next request for listing uploaded parts

MaxParts

string

Maximum number of listed parts, which is consistent with that set in the request

IsTruncated

boolean

Whether all uploaded parts are returned. If the field value is true, not all uploaded parts are returned. If the field value is false, all uploaded parts are returned.

Parts

indexed array

List of uploaded parts

  

PartNumber

integer

Part number

LastModified

string

Time when the part was last modified

ETag

string

Part ETag

Size

integer

Part size

Initiator

associative array

Initiator of the multipart upload

  

ID

string

ID of the domain to which the initiator belongs

DisplayName

string

Initiator name

Owner

associative array

Owner of the multipart upload, which is consistent with Initiator

  

ID

string

ID of the domain to which the initiator belongs

DisplayName

string

Initiator name

StorageClass

string

Storage class of the object to be uploaded

Sample Code

try {
       $resp = $obsClient->listParts( [ 
              'Bucket' => 'bucketname',
              'Key' => 'objectkey',
              'UploadId' => 'uploadid',
              'MaxParts' => 10
       ] );
       printf ( "RequestId:%s\n", $resp ['RequestId'] );
       printf ( "Initiator[ID]:%s\n", $resp ['Initiator']['ID'] );
       printf ( "Initiator[DisplayName]:%s\n", $resp ['Initiator']['DisplayName'] );
       foreach ($resp['Parts'] as $index => $part){
              printf("Parts[%d]\n", $index + 1);
              printf ( "PartNumber:%s\n", $part['PartNumber'] );
              printf ( "LastModified:%s\n", $part['LastModified'] );
              printf ( "ETag:%s\n", $part['ETag'] );
              printf ( "Size:%s\n", $part['Size'] );
       }
} catch ( Obs\Common\ObsException $obsException ) {
       printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () );
       printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () );
}