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 lastly being uploaded whose size ranging 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
1. ObsClient->uploadPart(array $parameter) 2. ObsClient->uploadPartAsync(array $parameter, callable $callback)
Request Parameter
| Field | Type | Optional or Mandatory | Description | 
|---|---|---|---|
| Bucket | string | Mandatory | Bucket name | 
| Key | string | Mandatory | Object name | 
| PartNumber | integer | Mandatory | Part number, which ranges from 1 to 10000 | 
| UploadId | string | Mandatory | Multipart upload ID | 
| ContentMD5 | string | Optional | Base64-encoded MD5 value of the part to be uploaded. It is provided for the OBS server to verify data integrity. | 
| Body | string or resource or GuzzleHttp\Psr7\StreamInterface | Optional | Part content to be uploaded | 
| SourceFile | string | Optional | Path to the source file of the part | 
| Offset | integer | Optional | Start offset (in bytes) of a part in the source file. The default value is 0. | 
| PartSize | integer | Optional | Size (in bytes) of a part in the source file. The default value is the file size minus Offset. Except for the part lastly being uploaded whose size ranging from 0 to 5 GB, sizes of the other parts range from 100 KB to 5 GB. | 
| SseC | string | Optional | Algorithm used in SSE-C encryption. The value can be: 
 | 
| SseCKey | string | Optional | Key used in SSE-C encryption. It is calculated by using AES-256. | 
 
 
   - Body and SourceFile cannot be used together.
- If both Body and SourceFile are null, the size of the object to be uploaded is 0 bytes.
- Offset, PartSize, and SourceFile are used together to specify a part of the source file to be uploaded.
Returned Result
| Field | Type | Description | 
|---|---|---|
| HttpStatusCode | integer | HTTP status code | 
| Reason | string | Reason description | 
| RequestId | string | Request ID returned by the OBS server | 
| ETag | string | ETag of the uploaded part | 
| SseKms | string | Algorithm used in SSE-KMS encryption | 
| SseKmsKey | string | Key used in SSE-KMS encryption | 
| SseC | string | Algorithm used in SSE-C encryption | 
| SseCKeyMd5 | string | MD5 value of the key used in SSE-C encryption | 
Sample Code
try { $resp = $obsClient->uploadPart( [ 'Bucket' => 'bucketname', 'Key' => 'objectkey', 'UploadId' => 'uploadid', 'PartNumber' => 1, 'Body' => 'Hello OBS' ] ); printf ( "RequestId:%s\n", $resp ['RequestId'] ); printf ( "ETag:%s\n", $resp ['ETag'] ); } catch ( Obs\Common\ObsException $obsException ) { printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () ); printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () ); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
 
    