| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.|
| callback | AsyncCallback<[UploadTask](#uploadtask)> | Yes| Callback used to return the **UploadTask** object.|
**Example**
**Example**
...
@@ -292,10 +292,10 @@ Subscribes to upload progress events. This API uses a callback to return the res
...
@@ -292,10 +292,10 @@ Subscribes to upload progress events. This API uses a callback to return the res
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).|
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (upload progress).|
| callback | function | Yes| Callback for the upload progress event.|
| callback | function | Yes| Callback for the upload progress event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -326,10 +326,10 @@ Subscribes to HTTP header events for an upload task. This API uses a callback to
...
@@ -326,10 +326,10 @@ Subscribes to HTTP header events for an upload task. This API uses a callback to
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).|
| type | string | Yes| Type of the event to subscribe to. The value is **'headerReceive'** (response header).|
| callback | function | Yes| Callback for the HTTP Response Header event.|
| callback | function | Yes| Callback for the HTTP Response Header event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -359,10 +359,10 @@ Subscribes to upload completion or failure events. This API uses a callback to r
...
@@ -359,10 +359,10 @@ Subscribes to upload completion or failure events. This API uses a callback to r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.|
| callback | Callback<Array<TaskState>> | Yes| Callback used to return the result.|
Parameters of the callback function
Parameters of the callback function
...
@@ -401,10 +401,10 @@ Unsubscribes from upload progress events. This API uses a callback to return the
...
@@ -401,10 +401,10 @@ Unsubscribes from upload progress events. This API uses a callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (upload progress).|
| callback | function | No| Callback used to return the result.<br>**uploadedSize**: size of the uploaded files, in B.<br>**totalSize**: Total size of the files to upload, in B.|
| callback | function | No| Callback used to return the result.<br>**uploadedSize**: size of the uploaded files, in B.<br>**totalSize**: Total size of the files to upload, in B.|
**Example**
**Example**
...
@@ -428,10 +428,10 @@ Unsubscribes from HTTP header events for an upload task. This API uses a callbac
...
@@ -428,10 +428,10 @@ Unsubscribes from HTTP header events for an upload task. This API uses a callbac
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'headerReceive'** (response header).|
| callback | function | No| Callback used to return the result.<br>**header**: HTTP response header.|
| callback | function | No| Callback used to return the result.<br>**header**: HTTP response header.|
**Example**
**Example**
...
@@ -454,10 +454,10 @@ Unsubscribes from upload completion or failure events. This API uses a callback
...
@@ -454,10 +454,10 @@ Unsubscribes from upload completion or failure events. This API uses a callback
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| type | string | Yes| Type of the event to subscribe to. The value **'complete'** means the upload completion event, and **'fail'** means the upload failure event.|
| callback | Callback<Array<TaskState>> | No| Callback used to return the result.<br>**taskstates**: upload task result.|
| callback | Callback<Array<TaskState>> | No| Callback used to return the result.<br>**taskstates**: upload task result.|
**Example**
**Example**
...
@@ -490,19 +490,15 @@ Deletes this upload task. This API uses a promise to return the result.
...
@@ -490,19 +490,15 @@ Deletes this upload task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
**Example**
**Example**
```js
```js
uploadTask.delete().then((result)=>{
uploadTask.delete().then((result)=>{
if(result){
console.info('Succeeded in deleting the upload task.');
console.info('Succeeded in deleting the upload task.');
}else{
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -521,9 +517,9 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
...
@@ -521,9 +517,9 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -533,11 +529,7 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
...
@@ -533,11 +529,7 @@ Deletes this upload task. This API uses an asynchronous callback to return the r
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in deleting the upload task.');
console.info('Succeeded in deleting the upload task.');
}else{
console.error(`Failed to delete the upload task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -558,19 +550,15 @@ Removes this upload task. This API uses a promise to return the result.
...
@@ -558,19 +550,15 @@ Removes this upload task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
| Promise<boolean> | Promise used to return the task removal result. It returns **true** if the operation is successful and returns **false** otherwise.|
**Example**
**Example**
```js
```js
uploadTask.remove().then((result)=>{
uploadTask.remove().then((result)=>{
if(result){
console.info('Succeeded in removing the upload task.');
console.info('Succeeded in removing the upload task.');
}else{
console.error(`Failed to remove the upload task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to remove the upload task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to remove the upload task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -593,9 +581,9 @@ Removes this upload task. This API uses an asynchronous callback to return the r
...
@@ -593,9 +581,9 @@ Removes this upload task. This API uses an asynchronous callback to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -681,26 +669,26 @@ Downloads files. This API uses a promise to return the result. You can use [on('
...
@@ -681,26 +669,26 @@ Downloads files. This API uses a promise to return the result. You can use [on('
| callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.|
| callback | AsyncCallback<[DownloadTask](#downloadtask)> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -869,10 +857,10 @@ Subscribes to download progress events. This API uses a callback to return the r
...
@@ -869,10 +857,10 @@ Subscribes to download progress events. This API uses a callback to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| type | string | Yes| Type of the event to subscribe to. The value is **'progress'** (download progress).|
| callback | function | Yes| Callback used to return the result.|
| callback | function | Yes| Callback used to return the result.|
Parameters of the callback function
Parameters of the callback function
...
@@ -903,10 +891,10 @@ Unsubscribes from download progress events. This API uses a callback to return t
...
@@ -903,10 +891,10 @@ Unsubscribes from download progress events. This API uses a callback to return t
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'progress'** (download progress).|
| callback | function | No| Callback used to return the result.<br>**receivedSize**: size of the downloaded files.<br>**totalSize**: total size of the files to download.|
| callback | function | No| Callback used to return the result.<br>**receivedSize**: size of the downloaded files.<br>**totalSize**: total size of the files to download.|
**Example**
**Example**
...
@@ -930,10 +918,10 @@ Subscribes to download events. This API uses an asynchronous callback to return
...
@@ -930,10 +918,10 @@ Subscribes to download events. This API uses an asynchronous callback to return
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to.<br>- **'complete'**: download task completion event.<br>- **'pause'**: download task pause event.<br>- **'remove'**: download task removal event.|
| type | string | Yes| Type of the event to subscribe to.<br>- **'complete'**: download task completion event.<br>- **'pause'**: download task pause event.<br>- **'remove'**: download task removal event.|
| callback | function | Yes| Callback used to return the result.|
| callback | function | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -967,10 +955,10 @@ Unsubscribes from download events. This API uses a callback to return the result
...
@@ -967,10 +955,10 @@ Unsubscribes from download events. This API uses a callback to return the result
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from.<br>- **'complete'**: download task completion event.<br>- **'pause'**: download task pause event.<br>- **'remove'**: download task removal event.|
| type | string | Yes| Type of the event to unsubscribe from.<br>- **'complete'**: download task completion event.<br>- **'pause'**: download task pause event.<br>- **'remove'**: download task removal event.|
| callback | function | No| Callback used to return the result.|
| callback | function | No| Callback used to return the result.|
**Example**
**Example**
...
@@ -1004,10 +992,10 @@ Subscribes to download failure events. This API uses a callback to return the re
...
@@ -1004,10 +992,10 @@ Subscribes to download failure events. This API uses a callback to return the re
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).|
| type | string | Yes| Type of the event to subscribe to. The value is **'fail'** (download failure).|
| callback | function | Yes| Callback for the download task failure event.|
| callback | function | Yes| Callback for the download task failure event.|
Parameters of the callback function
Parameters of the callback function
...
@@ -1037,10 +1025,10 @@ Unsubscribes from download failure events. This API uses a callback to return th
...
@@ -1037,10 +1025,10 @@ Unsubscribes from download failure events. This API uses a callback to return th
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).|
| type | string | Yes| Type of the event to unsubscribe from. The value is **'fail'** (download failure).|
| callback | function | No| Callback used to return the result.<br>**err**: error code of the download failure. |
| callback | function | No| Callback used to return the result.<br>**err**: error code of the download failure. |
**Example**
**Example**
...
@@ -1063,19 +1051,15 @@ Removes this download task. This API uses a promise to return the result.
...
@@ -1063,19 +1051,15 @@ Removes this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result.|
| Promise<boolean> | Promise used to return the task removal result.|
**Example**
**Example**
```js
```js
downloadTask.delete().then((result)=>{
downloadTask.delete().then((result)=>{
if(result){
console.info('Succeeded in removing the download task.');
console.info('Succeeded in removing the download task.');
}else{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -1094,9 +1078,9 @@ Deletes this download task. This API uses an asynchronous callback to return the
...
@@ -1094,9 +1078,9 @@ Deletes this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.|
**Example**
**Example**
...
@@ -1106,11 +1090,7 @@ Deletes this download task. This API uses an asynchronous callback to return the
...
@@ -1106,11 +1090,7 @@ Deletes this download task. This API uses an asynchronous callback to return the
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in removing the download task.');
console.info('Succeeded in removing the download task.');
}else{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1127,9 +1107,9 @@ Obtains the information about this download task. This API uses a promise to ret
...
@@ -1127,9 +1107,9 @@ Obtains the information about this download task. This API uses a promise to ret
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.|
| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.|
**Example**
**Example**
...
@@ -1154,9 +1134,9 @@ Obtains the information about this download task. This API uses an asynchronous
...
@@ -1154,9 +1134,9 @@ Obtains the information about this download task. This API uses an asynchronous
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.|
| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.|
**Example**
**Example**
...
@@ -1183,9 +1163,9 @@ Obtains the **MimeType** of this download task. This API uses a promise to retur
...
@@ -1183,9 +1163,9 @@ Obtains the **MimeType** of this download task. This API uses a promise to retur
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<string> | Promise used to return the **MimeType** of the download task.|
| Promise<string> | Promise used to return the **MimeType** of the download task.|
**Example**
**Example**
...
@@ -1210,9 +1190,9 @@ Obtains the **MimeType** of this download task. This API uses an asynchronous ca
...
@@ -1210,9 +1190,9 @@ Obtains the **MimeType** of this download task. This API uses an asynchronous ca
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.|
| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.|
**Example**
**Example**
...
@@ -1239,19 +1219,15 @@ Pauses this download task. This API uses a promise to return the result.
...
@@ -1239,19 +1219,15 @@ Pauses this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the download task pause result.|
| Promise<boolean> | Promise used to return the download task pause result.|
**Example**
**Example**
```js
```js
downloadTask.suspend().then((result)=>{
downloadTask.suspend().then((result)=>{
if(result){
console.info('Succeeded in pausing the download task.');
console.info('Succeeded in pausing the download task.');
}else{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -1270,9 +1246,9 @@ Pauses this download task. This API uses an asynchronous callback to return the
...
@@ -1270,9 +1246,9 @@ Pauses this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -1282,11 +1258,7 @@ Pauses this download task. This API uses an asynchronous callback to return the
...
@@ -1282,11 +1258,7 @@ Pauses this download task. This API uses an asynchronous callback to return the
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in pausing the download task.');
console.info('Succeeded in pausing the download task.');
}else{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1303,19 +1275,14 @@ Resumes this download task. This API uses a promise to return the result.
...
@@ -1303,19 +1275,14 @@ Resumes this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the result.|
| Promise<boolean> | Promise used to return the result.|
**Example**
**Example**
```js
```js
downloadTask.restore().then((result)=>{
downloadTask.restore().then((result)=>{
if(result){
console.info('Succeeded in resuming the download task.')
}else{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
}
console.info('Succeeded in resuming the download task.')
console.info('Succeeded in resuming the download task.')
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
...
@@ -1335,9 +1302,9 @@ Resumes this download task. This API uses an asynchronous callback to return the
...
@@ -1335,9 +1302,9 @@ Resumes this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -1347,11 +1314,7 @@ Resumes this download task. This API uses an asynchronous callback to return the
...
@@ -1347,11 +1314,7 @@ Resumes this download task. This API uses an asynchronous callback to return the
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in resuming the download task.');
console.info('Succeeded in resuming the download task.');
}else{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1372,19 +1335,15 @@ Removes this download task. This API uses a promise to return the result.
...
@@ -1372,19 +1335,15 @@ Removes this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the task removal result.|
| Promise<boolean> | Promise used to return the task removal result.|
**Example**
**Example**
```js
```js
downloadTask.remove().then((result)=>{
downloadTask.remove().then((result)=>{
if(result){
console.info('Succeeded in removing the download task.');
console.info('Succeeded in removing the download task.');
}else{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -1407,9 +1366,9 @@ Removes this download task. This API uses an asynchronous callback to return the
...
@@ -1407,9 +1366,9 @@ Removes this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.|
| callback | AsyncCallback<boolean> | Yes| Callback used to return the task deletion result.|
**Example**
**Example**
...
@@ -1419,11 +1378,7 @@ Removes this download task. This API uses an asynchronous callback to return the
...
@@ -1419,11 +1378,7 @@ Removes this download task. This API uses an asynchronous callback to return the
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in removing the download task.');
console.info('Succeeded in removing the download task.');
}else{
console.error(`Failed to remove the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1444,9 +1399,9 @@ Queries this download task. This API uses a promise to return the result.
...
@@ -1444,9 +1399,9 @@ Queries this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.|
| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information.|
**Example**
**Example**
...
@@ -1475,9 +1430,9 @@ Queries this download task. This API uses an asynchronous callback to return the
...
@@ -1475,9 +1430,9 @@ Queries this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.|
| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes| Callback used to return the download task information.|
**Example**
**Example**
...
@@ -1508,9 +1463,9 @@ Queries the **MimeType** of this download task. This API uses a promise to retur
...
@@ -1508,9 +1463,9 @@ Queries the **MimeType** of this download task. This API uses a promise to retur
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<string> | Promise used to return the **MimeType** of the download task.|
| Promise<string> | Promise used to return the **MimeType** of the download task.|
**Example**
**Example**
...
@@ -1539,9 +1494,9 @@ Queries the **MimeType** of this download task. This API uses an asynchronous ca
...
@@ -1539,9 +1494,9 @@ Queries the **MimeType** of this download task. This API uses an asynchronous ca
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.|
| callback | AsyncCallback<string> | Yes| Callback used to return the **MimeType** of the download task.|
**Example**
**Example**
...
@@ -1572,19 +1527,15 @@ Pauses this download task. This API uses a promise to return the result.
...
@@ -1572,19 +1527,15 @@ Pauses this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the download task pause result.|
| Promise<void> | Promise used to return the download task pause result.|
**Example**
**Example**
```js
```js
downloadTask.pause().then((result)=>{
downloadTask.pause().then((result)=>{
if(result){
console.info('Succeeded in pausing the download task.');
console.info('Succeeded in pausing the download task.');
}else{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
}
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -1607,9 +1558,9 @@ Pauses this download task. This API uses an asynchronous callback to return the
...
@@ -1607,9 +1558,9 @@ Pauses this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -1619,11 +1570,7 @@ Pauses this download task. This API uses an asynchronous callback to return the
...
@@ -1619,11 +1570,7 @@ Pauses this download task. This API uses an asynchronous callback to return the
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in pausing the download task.');
console.info('Succeeded in pausing the download task.');
}else{
console.error(`Failed to pause the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1644,19 +1591,14 @@ Resumes this download task. This API uses a promise to return the result.
...
@@ -1644,19 +1591,14 @@ Resumes this download task. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
**Example**
```js
```js
downloadTask.resume().then((result)=>{
downloadTask.resume().then((result)=>{
if(result){
console.info('Succeeded in resuming the download task.')
}else{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
}
console.info('Succeeded in resuming the download task.')
console.info('Succeeded in resuming the download task.')
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
...
@@ -1680,9 +1622,9 @@ Resumes this download task. This API uses an asynchronous callback to return the
...
@@ -1680,9 +1622,9 @@ Resumes this download task. This API uses an asynchronous callback to return the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -1692,11 +1634,7 @@ Resumes this download task. This API uses an asynchronous callback to return the
...
@@ -1692,11 +1634,7 @@ Resumes this download task. This API uses an asynchronous callback to return the
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
return;
return;
}
}
if(result){
console.info('Succeeded in resuming the download task.');
console.info('Succeeded in resuming the download task.');
}else{
console.error(`Failed to resume the download task. Code: ${err.code}, message: ${err.message}`);
}
});
});
```
```
...
@@ -1800,7 +1738,7 @@ Describes the form item of a task.
...
@@ -1800,7 +1738,7 @@ Describes the form item of a task.
| value | string \|[FileSpec](#filespec10)\| Array<[FileSpec](#filespec10)> | Yes| Form parameter value.|
| value | string \|[FileSpec](#filespec10)\| Array<[FileSpec](#filespec10)> | Yes| Form parameter value.|
## Conf<sup>10+</sup>
## Config<sup>10+</sup>
Provides the configuration information of an upload or download task.
Provides the configuration information of an upload or download task.
| url | string | Yes| Resource URL. The value contains a maximum of 2048 characters.|
| url | string | Yes| Resource URL. The value contains a maximum of 2048 characters.|
| title | string | No| Task title. The value contains a maximum of 256 characters. This parameter is left blank by default.|
| title | string | No| Task title. The value contains a maximum of 256 characters. The default value is a null string.|
| description | string | No| Task description. The value contains a maximum of 1024 characters. The default value is a null string.|
| description | string | No| Task description. The value contains a maximum of 1024 characters. The default value is a null string.|
| mode | [Mode](#mode10) | No| Task mode. The default mode is background.<br>- For a foreground task, a callback is used for notification.<br>- For a background task, the system notification and network connection features (detection, recovery, and automatic retry) are provided.|
| mode | [Mode](#mode10) | No| Task mode. The default mode is background.<br>- For a foreground task, a callback is used for notification.<br>- For a background task, the system notification and network connection features (detection, recovery, and automatic retry) are provided.|
| overwrite | boolean | No| Whether to overwrite an existing file during the download. The default value is **false**.<br>- **true**: Overwrite the existing file.<br>- **false**: Do not overwrite the existing file. In this case, the download fails.|
| overwrite | boolean | No| Whether to overwrite an existing file during the download. The default value is **false**.<br>- **true**: Overwrite the existing file.<br>- **false**: Do not overwrite the existing file. In this case, the download fails.|
| method | string | No| Standard HTTP method for the task. The value can be **GET**, **POST**, or **PUT**, which is case-insensitive.<br>- If the task is an upload, use **PUT** or **POST**. The default value is **PUT**.<br>- If the task is a download, use **GET** or **POST**. The default value is **GET**.|
| method | string | No| Standard HTTP method for the task. The value can be **GET**, **POST**, or **PUT**, which is case-insensitive.<br>- If the task is an upload, use **PUT** or **POST**. The default value is **PUT**.<br>- If the task is a download, use **GET** or **POST**. The default value is **GET**.|
| headers | object | No| HTTPS headers to be included in the task.<br>- If the task is an upload, the default **Content-Type** is **multipart/form-data**.<br>- If the task is a download, the default **Content-Type** is **application/json**.|
| headers | object | No| HTTPS headers to be included in the task.<br>- If the task is an upload, the default **Content-Type** is **multipart/form-data**.<br>- If the task is a download, the default **Content-Type** is **application/json**.|
| data | string \| Array<[FormItem](#formitem10)> | No| Task data.<br>- If the task is a download, the value is a string, typically in JSON format (an object will be converted to a JSON string); the default value is null.<br>- If the task is an upload, the value is Array<[FormItem](#formitem10)>; the default value is null.|
| data | string \| Array<[FormItem](#formitem10)> | No| Task data.<br>- If the task is a download, the value is a string, typically in JSON format (an object will be converted to a JSON string); the default value is null.<br>- If the task is an upload, the value is Array<[FormItem](#formitem10)>; the default value is null.|
| saveas | string | No| Path for storing downloaded files. The options are as follows:<br>- Relative path in the cache folder of the invoker, for example, ./xxx/yyy/zzz.html and xxx/yyy/zzz.html.<br>- URI (applicable when the application has the permission to access the URI), for example, **"datashare://bundle/xxx/yyy/zzz.html"**. Currently, this type is not supported.<br>The default value is a relative path in the cache folder of the application.|
| saveas | string | No| Path for storing downloaded files. The options are as follows:<br>- Relative path in the cache folder of the invoker, for example, **"./xxx/yyy/zzz.html"** and **"xxx/yyy/zzz.html"**.<br>- URI (applicable when the application has the permission to access the URI), for example, **"datashare://bundle/xxx/yyy/zzz.html"**. This option is not supported currently.<br>The default value is a relative path in the cache folder of the application.|
| network | [Network](#network10) | No| Network used for the task. The default value is **ANY** (Wi-Fi or cellular).|
| network | [Network](#network10) | No| Network used for the task. The default value is **ANY** (Wi-Fi or cellular).|
| metered | boolean | No| Whether the task is allowed on a metered connection. The default value is **false**.|
| metered | boolean | No| Whether the task is allowed on a metered connection. The default value is **false**.<br>- **true**: The task is allowed on a metered connection.<br>- **false**: The task is not allowed on a metered connection.|
| roaming | boolean | No| Whether the task is allowed on a roaming network. The default value is **true**.|
| roaming | boolean | No| Whether the task is allowed on a roaming network. The default value is **true**.<br>- **true**: The task is allowed on a roaming network.<br>- **false**: The task is not allowed on a roaming network.|
| retry | boolean | No| Whether automatic retry is enabled for background tasks. The default value is **true**.|
| retry | boolean | No| Whether automatic retry is enabled for the task. This parameter is only applicable to background tasks. The default value is **true**.<br>- **true**: Automatic retry is enabled for the task.<br>- **-false**: Automatic retry is not enabled for the task.|
| redirect | boolean | No| Whether redirection is allowed. The default value is **true**.|
| redirect | boolean | No| Whether redirection is allowed. The default value is **true**.<br>- **true**: Redirection is allowed.<br>- **false**: Redirection is not allowed.|
| index | number | No| Path index of the task. It is usually used for resumable downloads. The default value is **0**.|
| index | number | No| Path index of the task. It is usually used for resumable downloads. The default value is **0**.|
| begins | number | No| File start point of the task. It is usually used for resumable downloads. The default value is **0**. The value is a closed interval.<br>- If the task is a download, the value is obtained by sending an HTTP range request to read the start position when the server starts to download files.<br>- If the task is an upload, the value is obtained at the beginning of the upload.|
| begins | number | No| File start point of the task. It is usually used for resumable downloads. The default value is **0**. The value is a closed interval.<br>- If the task is a download, the value is obtained by sending an HTTP range request to read the start position when the server starts to download files.<br>- If the task is an upload, the value is obtained at the beginning of the upload.|
| ends | number | No| File end point of the task. It is usually used for resumable downloads. The default value is **-1**. The value is a closed interval.<br>- If the task is a download, the value is obtained by sending an HTTP range request to read the end position when the server starts to download files.<br>- If the task is an upload, the value is obtained at the end of the upload.|
| ends | number | No| File end point of the task. It is usually used for resumable downloads. The default value is **-1**. The value is a closed interval.<br>- If the task is a download, the value is obtained by sending an HTTP range request to read the end position when the server starts to download files.<br>- If the task is an upload, the value is obtained at the end of the upload.|
| gauge | boolean | No| Whether to send progress notifications. This parameter applies only to background tasks. The default value is **false**.<br>- **false**: Progress notifications are not sent. This means that a notification is sent only to indicate the result of the total task.<br>- **true**: Progress notifications are sent to indicate the result of each file.|
| gauge | boolean | No| Whether to send progress notifications. This parameter applies only to background tasks. The default value is **false**.<br>- **false**: Progress notifications are not sent. This means that a notification is sent only to indicate the result of the total task.<br>- **true**: Progress notifications are sent to indicate the result of each file.|
| precise | boolean | No| - If this parameter is set to **true**, the task fails when the file size cannot be obtained.<br>- If this parameter is set to **false**, the task continues when the file size is set to **-1**.<br>The default value is **false**.|
| precise | boolean | No| - If this parameter is set to **true**, the task fails when the file size cannot be obtained.<br>- If this parameter is set to **false**, the task continues when the file size is set to **-1**.<br>The default value is **false**.|
| token | string | No| Token of the task. If the task has a token configured, this token is required for query of the task. The value contains 8 to 2048 bytes. This parameter is left empty by default.|
| token | string | No| Token of the task. If the task has a token configured, this token is required for query of the task. The value contains 8 to 2048 bytes. This parameter is left empty by default.|
| extras | object | No| Additional information of the task. This parameter is left blank by default.|
| extras | object | No| Additional information of the task. This parameter is left empty by default.|
## State<sup>10+</sup>
## State<sup>10+</sup>
...
@@ -1838,7 +1776,7 @@ Defines the current task status.
...
@@ -1838,7 +1776,7 @@ Defines the current task status.
| Name| Value|Description|
| Name| Value|Description|
| -------- | -------- |-------- |
| -------- | -------- |-------- |
| INITIALIZED | 0x00 |The task is initialized based on the configuration specified in [Conf](#conf10).|
| INITIALIZED | 0x00 |The task is initialized based on the configuration specified in [Conf](#config10).|
| WAITING | 0x10 |The task lacks resources for running or the resources for retries do not match the network status.|
| WAITING | 0x10 |The task lacks resources for running or the resources for retries do not match the network status.|
| RUNNING | 0x20 |The task is being executed.|
| RUNNING | 0x20 |The task is being executed.|
| RETRYING | 0x21 |The task has failed at least once and is being executed again.|
| RETRYING | 0x21 |The task has failed at least once and is being executed again.|
...
@@ -1863,7 +1801,7 @@ Describes the data structure of the task progress.
...
@@ -1863,7 +1801,7 @@ Describes the data structure of the task progress.
| extras | object | No| Extra information of the task, for example, the header and body of the response from the server.|
| extras | object | No| Extra information of the task, for example, the header and body of the response from the server.|
## Broken<sup>10+</sup>
## Faults<sup>10+</sup>
Defines the cause of a task failure.
Defines the cause of a task failure.
...
@@ -1878,8 +1816,22 @@ Defines the cause of a task failure.
...
@@ -1878,8 +1816,22 @@ Defines the cause of a task failure.
| FSIO | 0x40 |File system I/O error, for example, an error that occurs during the open, search, read, write, or close operation.|
| FSIO | 0x40 |File system I/O error, for example, an error that occurs during the open, search, read, write, or close operation.|
@@ -1887,8 +1839,9 @@ Defines the data structure of the task information for query. The fields availab
...
@@ -1887,8 +1839,9 @@ Defines the data structure of the task information for query. The fields availab
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| uid | string | No| UID of the application. It is only available for query by system applications.<br>**System API**: This is a system API.|
| uid | string | No| UID of the application. It is only available for query by system applications.<br>**System API**: This is a system API.|
| bundle | string | No| Bundle name of the application. It is only available for query by system applications.<br>**System API**: This is a system API.|
| bundle | string | No| Bundle name of the application. It is only available for query by system applications.<br>**System API**: This is a system API.|
| url | string | No| Task URL. It is only available for query by non-system applications. An empty string is returned for query by system applications.|
| saveas | string | No| Path for storing downloaded files. The options are as follows:<br>- Relative path in the cache folder of the invoker, for example, **"./xxx/yyy/zzz.html"** and **"xxx/yyy/zzz.html"**.<br>- URI (applicable when the application has the permission to access the URI), for example, **"datashare://bundle/xxx/yyy/zzz.html"**. This option is not supported currently.<br>The default value is a relative path in the cache folder of the application.|
| data | string \| Array<[FormItem](#formitem10)> | No| Task value.|
| url | string | No| Task URL.<br>- It can be obtained through [request.agent.show<sup>10+</sup>](#requestagentshow10-1), [request.agent.touch<sup>10+</sup>](#requestagenttouch10-1), or [request.agent.query<sup>10+</sup>](#requestagentquery10-1). When [request.agent.query<sup>10+</sup>](#requestagentquery10-1) is used, an empty string is returned.|
| data | string \| Array<[FormItem](#formitem10)> | No| Task value.<br>- It can be obtained through [request.agent.show<sup>10+</sup>](#requestagentshow10-1), [request.agent.touch<sup>10+</sup>](#requestagenttouch10-1), or [request.agent.query<sup>10+</sup>](#requestagentquery10-1). When [request.agent.query<sup>10+</sup>](#requestagentquery10-1) is used, an empty string is returned.|
| tid | string | Yes| Task ID.|
| tid | string | Yes| Task ID.|
| title | string | Yes| Task title.|
| title | string | Yes| Task title.|
| description | string | Yes| Task description.|
| description | string | Yes| Task description.|
...
@@ -1897,11 +1850,11 @@ Defines the data structure of the task information for query. The fields availab
...
@@ -1897,11 +1850,11 @@ Defines the data structure of the task information for query. The fields availab
| mimeType | string | Yes| MIME type in the task configuration.|
| mimeType | string | Yes| MIME type in the task configuration.|
| gauge | boolean | Yes| Whether to send progress notifications. This parameter applies only to background tasks.|
| gauge | boolean | Yes| Whether to send progress notifications. This parameter applies only to background tasks.|
| ctime | string | Yes| Date and time when a task is created in UTC mode. The value is generated by the system of the current device.|
| ctime | number | Yes| Unix timestamp when the task is created, in milliseconds. The value is generated by the system of the current device.<br>Note: When [request.agent.search<sup>10+</sup>](#requestagentsearch10-1) is used for query, this value must be within the range of [after,before] for the task ID to be obtained. For details about **before** and **after**, see [Filter](#filter10).
| mtime | string | Yes| Date and time when a task is modified in UTC mode. The value is generated by the system of the current device.|
| mtime | number | Yes| Unix timestamp when the task state changes, in milliseconds. The value is generated by the system of the current device.|
| retry | boolean | Yes| Whether automatic retry is enabled for the task. This parameter applies only to background tasks.|
| retry | boolean | Yes| Whether automatic retry is enabled for the task. This parameter applies only to background tasks.|
| tries | number | Yes| Number of retries of the task.|
| tries | number | Yes| Number of retries of the task.|
| broken | [Broken](#broken10) | Yes| Failure cause of the task.<br>- **OTHERS**: other fault.<br>- **DISCONNECT**: network disconnection.<br>- **TIMEOUT**: timeout.<br>- **PROTOCOL**: protocol error.<br>- **FSIO**: file system I/O error.|
| faults | [Faults](#faults10) | Yes| Failure cause of the task.<br>- **OTHERS**: other fault.<br>- **DISCONNECT**: network disconnection.<br>- **TIMEOUT**: timeout.<br>- **PROTOCOL**: protocol error.<br>- **FSIO**: file system I/O error.|
| reason | string | Yes| Reason why the task is waiting, failed, stopped, or paused.|
| reason | string | Yes| Reason why the task is waiting, failed, stopped, or paused.|
| extras | string | No| Extra information of the task|
| extras | string | No| Extra information of the task|
...
@@ -1917,7 +1870,7 @@ Task attributes include the task ID and task configuration.
...
@@ -1917,7 +1870,7 @@ Task attributes include the task ID and task configuration.
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| tid | string | Yes| Task ID, which is unique in the system and is automatically generated by the system.|
| tid | string | Yes| Task ID, which is unique in the system and is automatically generated by the system.|
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
...
@@ -2368,24 +2321,24 @@ Starts this task. This API cannot be used to start an initialized task. This API
...
@@ -2368,24 +2321,24 @@ Starts this task. This API cannot be used to start an initialized task. This API
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
**Error codes**
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900007 | task state error. |
| 21900007 | task state error. |
**Example**
**Example**
```js
```js
letcontext;
letcontext;
letconf={
letconfig={
action:request.agent.Action.DOWNLOAD,
action:request.agent.Action.DOWNLOAD,
url:'http://127.0.0.1',
url:'http://127.0.0.1',
title:'taskStartTest',
title:'taskStartTest',
...
@@ -2407,7 +2360,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
...
@@ -2407,7 +2360,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
console.info(`Succeeded in starting a download task.`);
console.info(`Succeeded in starting a download task.`);
}).catch((err)=>{
}).catch((err)=>{
...
@@ -2502,25 +2455,25 @@ Pauses this task. This API can be used to pause a background task that is waitin
...
@@ -2502,25 +2455,25 @@ Pauses this task. This API can be used to pause a background task that is waitin
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
**Error codes**
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900005 | task mode error. |
| 21900005 | task mode error. |
| 21900007 | task state error. |
| 21900007 | task state error. |
**Example**
**Example**
```js
```js
letcontext;
letcontext;
letconf={
letconfig={
action:request.agent.Action.DOWNLOAD,
action:request.agent.Action.DOWNLOAD,
url:'http://127.0.0.1',
url:'http://127.0.0.1',
title:'taskPauseTest',
title:'taskPauseTest',
...
@@ -2542,7 +2495,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
...
@@ -2542,7 +2495,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
console.info(`Succeeded in pausing a download task. `);
console.info(`Succeeded in pausing a download task. `);
}).catch((err)=>{
}).catch((err)=>{
...
@@ -2632,25 +2585,25 @@ Resumes this task. This API can be used to resume a paused background task. This
...
@@ -2632,25 +2585,25 @@ Resumes this task. This API can be used to resume a paused background task. This
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
**Error codes**
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900005 | task mode error. |
| 21900005 | task mode error. |
| 21900007 | task state error. |
| 21900007 | task state error. |
**Example**
**Example**
```js
```js
letcontext;
letcontext;
letconf={
letconfig={
action:request.agent.Action.DOWNLOAD,
action:request.agent.Action.DOWNLOAD,
url:'http://127.0.0.1',
url:'http://127.0.0.1',
title:'taskResumeTest',
title:'taskResumeTest',
...
@@ -2672,7 +2625,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
...
@@ -2672,7 +2625,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
console.info(`Succeeded in resuming a download task. `);
console.info(`Succeeded in resuming a download task. `);
}).catch((err)=>{
}).catch((err)=>{
...
@@ -2762,24 +2715,24 @@ Stops this task. This API can be used to stop a running, waiting, or retrying ta
...
@@ -2762,24 +2715,24 @@ Stops this task. This API can be used to stop a running, waiting, or retrying ta
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | function | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
**Error codes**
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900007 | task state error. |
| 21900007 | task state error. |
**Example**
**Example**
```js
```js
letcontext;
letcontext;
letconf={
letconfig={
action:request.agent.Action.DOWNLOAD,
action:request.agent.Action.DOWNLOAD,
url:'http://127.0.0.1',
url:'http://127.0.0.1',
title:'taskStopTest',
title:'taskStopTest',
...
@@ -2801,7 +2754,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
...
@@ -2801,7 +2754,7 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
Creates an upload or download task and adds it to the queue. An application can create a maximum of 10 tasks, and a maximum of 300 tasks can be carried. This API uses an asynchronous callback to return the result.
Creates an upload or download task and adds it to the queue. An application can create a maximum of 10 tasks, and a maximum of 300 tasks can be carried. This API uses an asynchronous callback to return the result.
...
@@ -2890,22 +2843,22 @@ Creates an upload or download task and adds it to the queue. An application can
...
@@ -2890,22 +2843,22 @@ Creates an upload or download task and adds it to the queue. An application can
Creates an upload or download task and adds it to the queue. An application can create a maximum of 10 tasks, and a maximum of 300 tasks can be carried. This API uses a promise to return the result.
Creates an upload or download task and adds it to the queue. An application can create a maximum of 10 tasks, and a maximum of 300 tasks can be carried. This API uses a promise to return the result.
...
@@ -2967,10 +2920,10 @@ Creates an upload or download task and adds it to the queue. An application can
...
@@ -2967,10 +2920,10 @@ Creates an upload or download task and adds it to the queue. An application can
console.info(`Succeeded in creating a download task. result: ${task.conf}`);
console.info(`Succeeded in creating a download task. result: ${task.config}`);
}).catch((err)=>{
}).catch((err)=>{
console.error(`Failed to create a download task, Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to create a download task, Code: ${err.code}, message: ${err.message}`);
});
});
...
@@ -3044,19 +2997,19 @@ Removes a specified task of the invoker. If the task is being executed, the task
...
@@ -3044,19 +2997,19 @@ Removes a specified task of the invoker. If the task is being executed, the task
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| id | string | Yes| Task ID.|
| id | string | Yes| Task ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
**Error codes**
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900006 | task not found error. |
| 21900006 | task not found error. |
**Example**
**Example**
...
@@ -3081,9 +3034,9 @@ Removes a specified task of the invoker. If the task is being executed, the task
...
@@ -3081,9 +3034,9 @@ Removes a specified task of the invoker. If the task is being executed, the task
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| id | string | Yes| Task ID.|
| id | string | Yes| Task ID.|
**Return value**
**Return value**
...
@@ -3095,10 +3048,10 @@ Removes a specified task of the invoker. If the task is being executed, the task
...
@@ -3095,10 +3048,10 @@ Removes a specified task of the invoker. If the task is being executed, the task
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
For details about the error codes, see [Upload and Download Error Codes](../errorcodes/errorcode-request.md).
| ID| Error Message|
| ID| Error Message|
| -------- | -------- |
| -------- | -------- |
| 13400003 | task service ability error. |
| 13400003 | task service ability error. |
| 21900006 | task not found error. |
| 21900006 | task not found error. |
**Example**
**Example**
...
@@ -3110,4 +3063,322 @@ For details about the error codes, see [Upload and Download Error Codes](../erro
...
@@ -3110,4 +3063,322 @@ For details about the error codes, see [Upload and Download Error Codes](../erro