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
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 last uploaded whose size ranges 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 AES256. |
|
SseCKey |
string |
Optional |
Custom key used in SSE-C encryption. The value is a Base64-encoded 256-bit key. |
- 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 |
ID of the KMS master key used in SSE-KMS encryption. If this parameter is left blank, the default key is used. To obtain the key ID, see Viewing a Key. |
|
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot