Updated on 2026-01-16 GMT+08:00

Initiate Multipart Upload

API Description

You can use this API to initialize a multipart upload in a specified bucket.

Method Definition

1. ObsClient->initiateMultipartUpload(array $parameter)
2. ObsClient->initiateMultipartUploadAsync(array $parameter, callable $callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

string

Mandatory

Bucket name

Key

string

Mandatory

Object name

ACL

string

Optional

Pre-defined access control policy

StorageClass

string

Optional

Storage class of the object

Metadata

associative array

Optional

Customized metadata of the object

WebsiteRedirectLocation

string

Optional

Location where the object is redirected to, when the bucket is configured with website hosting.

ContentType

string

Optional

MIME type of the object. For details about the common content types, see .

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

Name of the bucket involved in the multipart upload

Key

string

Name of the object to be uploaded

UploadId

string

Multipart upload ID

Sample Code

try {
       $resp = $obsClient->initiateMultipartUpload( [ 
              'Bucket' => 'bucketname',
              'Key' => 'objectkey',
              'ContentType' => 'text/plain'
       ] );
       printf ( "RequestId:%s\n", $resp ['RequestId'] );
       printf ( "Bucket:%s\n", $resp ['Bucket'] );
       printf ( "Key:%s\n", $resp ['Key'] );
       printf ( "UploadId:%s\n", $resp ['UploadId'] );
} catch ( Obs\Common\ObsException $obsException ) {
       printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () );
       printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () );
}