• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Node.js SDK)
  4. Object Download
  5. Performing a Resumable Download

Performing a Resumable Download

Downloading large files often fails due to poor network conditions or program breakdowns. It is a waste of resources to restart the download process upon a download failure, and the restarted download process may still suffer from the unstable network. To resolve such issues, you can use the API for resumable download, whose working principle is to divide the to-be-downloaded file into multiple parts and download them separately. The download result of each part is recorded in a checkpoint file in real time. Only when all parts are successfully downloaded, the result indicating a successful download will be returned. Otherwise, an error is returned in callback function to remind you of calling the API again for re-downloading. Based on the download status of each part recorded in the checkpoint file, the re-downloading will download the parts failed to be downloaded previously, instead of downloading all parts. By virtue of this, resources are saved and efficiency is improved.

You can call ObsClient.downloadFile to perform a resumable download. The following table describes the main parameters involved in this API.




(Mandatory) Bucket name


(Mandatory) Object name


Full path of the local directory to which the object is downloaded. If this parameter is null, the downloaded object is saved in the directory where the program is executed.


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


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


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


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


Object version


Returns the object if it is modified after the time specified by this parameter; otherwise, an error code is returned.


Returns the object if it remains unchanged since the time specified by this parameter; otherwise, an error code is returned.


Returns the source object if its ETag is the same as the one specified by this parameter; otherwise, an error code is returned.


Returns the source object if its ETag is different from the one specified by this parameter; otherwise, an error code is returned.

Sample code:

// Import the OBS library.
var ObsClient = require('./lib/obs');

// Create an instance of ObsClient.
var obsClient = new ObsClient({
       access_key_id : '*** Provide your Access Key ***',
       secret_access_key : '*** Provide your Secret Key ***',
       server : 'yourdomainname'

       Bucket : 'bucketname',
       Key : 'objectkey',
      // Set the local path to which the object is downloaded.
       DownloadFile : 'localfile',
       // Set the part size to 10 MB.
       PartSize : 10 * 1024 * 1024,
       // Enable the resumable download mode.
       EnableCheckpoint : true
}, (err, result) => {
        console.error('Error-->' + err);
        console.log('RequestId-->' + result.InterfaceResult.RequestId);
        console.log('LastModified-->' + result.InterfaceResult.LastModified);
        console.log('Metadata-->' + JSON.stringify(result.InterfaceResult.Metadata)); 
  • The API for resumable download, which is implemented based on partial download, is an encapsulated and enhanced version of partial download.
  • This API saves resources and improves efficiency upon the re-download, and speeds up the download process by concurrently downloading parts. Because this API is transparent to users, users are free from concerns about internal service details, such as the creation and deletion of checkpoint files, division of objects, and concurrent download of parts.
  • The default value of the EnableCheckpoint parameter is false, which indicates that the resumable download mode is disabled. In such cases, this API degrades to the simple encapsulation of partial download, and no checkpoint file will be generated.
  • CheckpointFile is effective only when EnableCheckpoint is true.