• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Node.js SDK)
  4. Objects-Related APIs
  5. Initiate Multipart Upload

Initiate Multipart Upload

API Description

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

Method Definition

ObsClient.initiateMultipartUpload(parameter, 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 policy. Possible values are:

  • ObsClient.enums.AclPrivate
  • ObsClient.enums.AclPublicRead
  • ObsClient.enums.AclPublicReadWrite
  • ObsClient.enums.AclAuthenticatedRead
  • ObsClient.enums.AclBucketOwnerRead
  • ObsClient.enums.AclBucketOwnerFullControl

StorageClass

String

Optional

Storage class of the object. Possible values are:

  • ObsClient.enums.StorageClassStandard
  • ObsClient.enums.StorageClassWarm
  • ObsClient.enums.StorageClassCold

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

ContentType

String

Optional

MIME type of the object

SseKms

String

Optional

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

  • aws:kms

SseKmsKey

String

Optional

Master key used in SSE-KMS encryption. This field can be null.

SseC

String

Optional

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

  • AES256

SseCKey

Buffer

Optional

Key used to encrypt the object in SSE-C mode, which is calculated by using AES256

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

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

obsClient.initiateMultipartUpload({
       Bucket:'bucketname',
       Key : 'objectkey',
       ContentType : 'text/plain'
},(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);
              }
       }
});