• Object Storage Service

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

PUT Part

API Description

After a multipart upload is initialized, you can use this API to upload a part to a specified bucket by using the multipart upload ID. Except for the part last uploaded whose size ranges from 0 to 5 GB, sizes of the other parts range from 100 KB to 5 GB. The upload part ID ranges from 1 to 10000.

Method Definition

ObsClient.uploadPart(bucketName, objectKey, partNumber, uploadId, object, isFile, partSize, offset, sseHeader, isAttachMd5, md5)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

partNumber

int

Mandatory

Part number, which ranges from 1 to 10000

uploadId

str

Mandatory

Multipart upload ID

object

str

or

readable object

Mandatory

Part content to be uploaded

isFile

bool

Optional

Whether object indicates the file path. The default value is False.

offset

int

Optional

Start offset (in bytes) of a part in the source file. The default value is 0.

partSize

int

Optional

Size (in bytes) of a part in the source file. The default value is the file size minus offset.

sseHeader

SseCHeader

Optional

Header for server-side encryption

isAttachMd5

bool

Optional

Whether to automatically calculate the MD5 value of the data to be uploaded. If md5 is configured, this field will be ignored

md5

str

Optional

Base64-encoded MD5 value of the part to be uploaded. It is provided for the OBS server to verify data integrity.

NOTE:
  • If isAttachMd5 and md5 are used at the same time, md5 prevails.
  • If isFile is Trueobject indicates the path to the file to be uploaded. If isFile is False and object is a readable object that contains the read attribute, data can be read from the object, otherwise the object content is a character string.

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

UploadPartResponse

Response result of PUT Part

Sample Code

try:
    resp = obsClient.uploadPart('bucketname', 'objectkey', 1, 'uploadid', 'Hello OBS') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('etag:', resp.body.etag) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())