Performing a Resumable Download
API Description
This API is an encapsulated and enhanced version of multipart download, and aims to eliminate large file download failures caused by poor network conditions and program breakdowns.
Method Definition
ObsClient.downloadFile
Request Parameter
|
Field |
Type |
Optional or Mandatory |
Description |
|---|---|---|---|
|
Bucket |
String |
Mandatory |
Bucket name |
|
Key |
String |
Mandatory |
Object name |
|
DownloadFile |
String |
Optional |
Local path to which the object is downloaded. If this parameter is null, the downloaded object is saved in the directory where the program is executed. |
|
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 download. 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 download progress. This parameter is effective only in the resumable download mode. If this parameter is null, the file will be in the same directory as the local directory of the downloaded file. |
|
VersionId |
String |
Optional |
Object version ID |
|
IfModifiedSince |
String |
Optional |
Returns the object if it is modified after the time specified by this parameter; otherwise, an error code is returned. |
|
IfUnmodifiedSince |
String |
Optional |
Returns the object if it remains unchanged since the time specified by this parameter; otherwise, an error code is returned. |
|
IfMatch |
String |
Optional |
Returns the source object if its ETag is the same as the one specified by this parameter; otherwise, an error code is returned. |
|
IfNoneMatch |
String |
Optional |
Returns the source object if its ETag is different from the one specified by this parameter; otherwise, an error code is returned. |
|
SseC |
String |
Optional |
Algorithm used in SSE-C decryption. The value can be:
|
|
SseCKey |
String |
Optional |
Key used in SSE-C decryption, which is calculated by using AES256 |
Returned Result (InterfaceResult)
|
Field |
Type |
Description |
|---|---|---|
|
RequestId |
String |
Request ID returned by the OBS server |
|
DeleteMarker |
String |
Whether the deleted object is a delete marker |
|
LastModified |
String |
Time when the last modification was made to the object |
|
CacheControl |
String |
Cache-Control header in the response |
|
ContentDisposition |
String |
Content-Disposition header in the response |
|
ContentEncoding |
String |
Content-Encoding header in the response |
|
ContentLanguage |
String |
Content-Language header in the response |
|
ContentType |
String |
MIME type of the object |
|
Expires |
String |
Expires header in the response |
|
ETag |
String |
Object ETag |
|
VersionId |
String |
Object version ID |
|
WebsiteRedirectLocation |
String |
Location where the object is redirected to, when the bucket is configured with website hosting |
|
StorageClass |
String |
Storage class of the object. When the storage class is OBS Standard, the value is null. |
|
Restore |
String |
Restore status of the object in the OBS Archive storage class |
|
SseKms |
String |
Algorithm used in SSE-KMS decryption |
|
SseKmsKey |
String |
Master key used in SSE-KMS decryption |
|
SseC |
String |
Algorithm used in SSE-C decryption |
|
SseCKeyMd5 |
String |
MD5 value of the key used in SSE-C decryption |
|
Expiration |
String |
Expiration details |
|
Metadata |
Object |
Customized metadata of the object |
Sample Code
obsClient.downloadFile({
Bucket : 'bucketname',
Key : 'objectkey',
DownloadFile : 'localfile',
PartSize : 10 * 1024 * 1024,
EnableCheckpoint : true
}, (err, result) => {
if(err){
console.error('Error-->' + err);
}else{
console.log('RequestId-->' + result.InterfaceResult.RequestId);
console.log('LastModified-->' + result.InterfaceResult.LastModified);
console.log('Metadata-->' + JSON.stringify(result.InterfaceResult.Metadata));
}
});
Last Article: Performing a Resumable Upload
Next Article: Change History
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.