Updated on 2022-02-10 GMT+08:00

Initiate Multipart Upload

API Description

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

Method Definition

ObsClient.initiateMultipartUpload

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Key

String

Mandatory

Object name

RequestDate

String

or

Date

Optional

Request time

NOTE:

When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards.

ACL

String

Optional

Pre-defined access control policy specified during object creation

StorageClass

String

Optional

Storage class, which can be specified during the object creation

Metadata

Object

Optional

Customized metadata of the object

WebsiteRedirectLocation

String

Optional

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

Expires

Number

Optional

Expiration time of the object, in days

ContentType

String

Optional

MIME type of the object

SseKms

String

Optional

Algorithm used in SSE-KMS encryption. The value can be:

  • kms

SseKmsKey

String

Optional

Master key used in SSE-KMS encryption. The value can be null.

SseC

String

Optional

Algorithm used in SSE-C encryption. The value can be:

  • AES256

SseCKey

String

Optional

Key used in SSE-C encryption. It is calculated by using AES-256.

Returned Result (InterfaceResult)

Field

Type

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

obsClient.initiateMultipartUpload({
       Bucket:'bucketname',
       Key : 'objectkey',
       ContentType : 'text/plain'
},function (err, result) {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
                     console.log('Bucket-->' + result.InterfaceResult.Bucket);
                     console.log('Key-->' + result.InterfaceResult.Key);
                     console.log('UploadId-->' + result.InterfaceResult.UploadId);
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});