All Products
Search
Document Center

Object Storage Service:UploadPart

Last Updated:Apr 28, 2024

Uploads data by part based on the specified object name and upload ID after you initiate a multipart upload operation.

Usage notes

  • Before you call the UploadPart operation to upload data by part, you must call the InitiateMultipartUpload operation to obtain an upload ID generated by Object Storage Service (OSS).

  • If you use the same partNumber to upload a new part, the existing part that is uploaded by using the partNumber is overwritten.

  • OSS includes the MD5 hash of each received part in the ETag header of the response.

  • If the x-oss-server-side-encryption request header is specified when you call the InitiateMultipartUpload operation, the uploaded part is encrypted. The x-oss-server-side-encryption header is included in the response, which indicates the server-side encryption algorithm of the part. For more information, see InitiateMultipartUpload.

Request syntax

PUT /ObjectName?partNumber=PartNumber&uploadId=UploadId HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Content-Length: Size
Authorization: SignatureValue

Request headers

This request contains only common request headers. For more information, see Common HTTP headers.

Request elements

Element

Type

Required

Example

Description

partNumber

Positive integer

Yes

1

The number that identifies a part.

Valid values: 1 to 10000.

The size of a part ranges from 100 KB to 5 GB.

Note

In multipart upload, each part except the last part must be larger than or equal to 100 KB in size. The size of each part is not verified when you call the UploadPart operation because not all parts are uploaded and OSS cannot determine which part is the last part. The size of each part is verified only when you call the CompleteMultipartUpload operation.

uploadId

String

Yes

0004B9895DBBB6EC9****

The ID that identifies the object to which the parts to upload belong.

Response headers

Header

Type

Example

Description

Content-MD5

String

1B2M2Y8AsgTpgAmY7PhC****

The MD5 hash of the part.

Important

The MD5 hash of the part is obtained after the client uploads the object. It is not the MD5 hash in the response body.

x-oss-hash-crc64ecma

String

316181249502703****

The CRC-64 value of the part.

For more information about the common response headers, such as Date and x-oss-request-id, in the response to an UploadPart request, see Common HTTP headers.

Examples

Sample request

PUT /multipart.data?partNumber=1&uploadId=0004B9895DBBB6EC9****  HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 6291456
Date: Wed, 22 Feb 2012 08:32:21 GMT
Authorization: OSS qn6q**************:77Dv****************
[6291456 bytes data]

Sample response

HTTP/1.1 200 OK
Server: AliyunOSS
Content-length: 0
Connection: keep-alive
ETag: "7265F4D211B56873A381D321F586****"
x-oss-request-id: 3e6aba62-1eae-d246-6118-8ff42cd0****
Date: Wed, 22 Feb 2012 08:32:21 GMT
Content-MD5: 1B2M2Y8AsgTpgAmY7Ph****
x-oss-hash-crc64ecma: 316181249502703****
x-oss-server-time: 77

OSS SDKs

You can use OSS SDKs for the following programming languages to call the UploadPart operation:

Error codes

Error code

HTTP status code

Description

NoSuchUpload

404

The specified multipart upload ID does not exist.

InvalidArgument

400

The part number is not within the range of 1 to 10000.

InvalidDigest

400

The Content-MD5 value in the request is different from the MD5 hash calculated by OSS. To prevent errors during data transmission, you can include the Content-MD5 value in the request. OSS calculates the MD5 hash of the uploaded data and compares it with the Content-MD5 value in the request.