• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Node.js SDK)
  4. Other APIs
  5. Resumable Upload

Resumable Upload

API Description

This API is an encapsulated and enhanced version of multipart upload, and aims to eliminate large file upload failures caused by poor network conditions and program breakdowns.

Method Definition

ObsClient.uploadFile(parameter, callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Key

String

Mandatory

Object name

UploadFile

String

Mandatory

Local file to be uploaded

PartSize

Number

Optional

Part size, in bytes. The value ranges from 100 KB to 5 GB and defaults to 5 MB.

TaskNum

Number

Optional

Maximum number of threads that can be concurrently executed for upload. The default value is 20.

EnableCheckpoint

Boolean

Optional

Whether to enable the resumable upload mode. The default value is false, which indicates that this mode is disabled.

CheckpointFile

String

Optional

File used to record the upload progress. This parameter is effective only in the resumable upload mode. If this parameter is null, the file will be in the same directory as the local file to be uploaded.

EnableCheckSum

Boolean

Optional

Whether to verify the content of the to-be-uploaded file. This parameter is effective only in the resumable mode. The default value is false, which indicates that the content will not be verified.

ContentType

String

Optional

MIME type of the object

ACL

String

Optional

Pre-defined access policy. Possible values are:

  • private
  • public-read
  • public-read-write
  • authenticated-read
  • bucket-owner-read
  • bucket-owner-full-control

WebsiteRedirectLocation

String

Optional

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

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

String

Optional

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

Metadata

Object

Optional

Customized metadata of the object

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

ETag

String

ETag calculated based on the ETags of all combined parts

Bucket

String

Bucket in which parts are combined

Key

String

Object name obtained after part combination

Location

String

URL of the object obtained after part combination

VersionId

String

Version ID of the object obtained after part combination

SseKms

String

Algorithm used in SSE-KMS encryption

SseKmsKey

String

Master 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.uploadFile({
       Bucket : 'bucketname',
       Key : 'objectkey',
       UploadFile : 'localfile',
       PartSize : 10 * 1024 * 1024,
       EnableCheckpoint : true
}, (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('Location-->' + result.InterfaceResult.Location);
          }else{
                 console.log('Code-->' + result.CommonMsg.Code);
                 console.log('Message-->' + result.CommonMsg.Message);
          }
    }
});