diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
index d349ac3740e24fbec66e0f55e3e98e8ccab7de86..1ba5395b85a1bdbff81c26c46696238820b1eee2 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
@@ -1692,11 +1692,11 @@ off(type: 'insertText'): void
inputMethodController.off('insertText');
```
-### on('deleteLeft' | 'deleteRight')10+
+### on('deleteLeft')10+
-on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
+on(type: 'deleteLeft', callback: (length: number) => void): void
-订阅输入法应用向左删除或向右删除事件。使用callback异步回调。
+订阅输入法应用向左删除事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
@@ -1704,8 +1704,8 @@ on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----- | ---- | ----- |
-| type | string | 是 | 设置监听类型。
- type为‘deleteLeft’时表示订阅输入法应用向左删除事件监听。
- type为‘deleteRight’时表示订阅输入法应用向右删除事件监听。|
-| callback | (length: number) => void | 是 | 回调函数,返回需要向左或向右删除的文本的长度。
开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
+| type | string | 是 | 设置监听类型。
- type为`deleteLeft`表示订阅输入法应用向左删除事件监听。 |
+| callback | (length: number) => void | 是 | 回调函数,返回需要向左删除的文本的长度。
开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
**错误码:**
@@ -1725,7 +1725,34 @@ try {
} catch(err) {
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(err)}`);
}
+```
+
+### on('deleteRight')10+
+
+on(type: 'deleteRight', callback: (length: number) => void): void
+
+订阅输入法应用向右删除事件。使用callback异步回调。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ----- | ---- | ----- |
+| type | string | 是 | 设置监听类型。
- type为`deleteRight`表示订阅输入法应用向右删除事件监听。|
+| callback | (length: number) => void | 是 | 回调函数,返回需要向右删除的文本的长度。
开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
+
+**错误码:**
+
+以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。
+
+| 错误码ID | 错误信息 |
+| -------- | -------------------------------------- |
+| 12800009 | input method client is detached. |
+**示例:**
+
+```js
try {
inputMethodController.on('deleteRight', (length) => {
console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
@@ -1734,12 +1761,11 @@ try {
console.error(`Failed to subscribe deleteRight: ${JSON.stringify(err)}`);
}
```
+### off('deleteLeft')10+
-### off('deleteLeft' | 'deleteRight')10+
+off(type: 'deleteLeft'): void
-off(type: 'deleteLeft' | 'deleteRight'): void
-
-取消订阅输入法应用向左或向右删除文本事件。
+取消订阅输入法应用向左删除文本事件。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
@@ -1747,12 +1773,31 @@ off(type: 'deleteLeft' | 'deleteRight'): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
-| type | string | 是 | 设置监听类型。
- type为‘deleteLeft’时表示取消订阅输入法应用向左删除的事件监听。
- type为‘deleteRight’时表示取消订阅输入法应用向右删除的事件监听。|
+| type | string | 是 | 设置监听类型。
- type为`deleteLeft`表示取消订阅输入法应用向左删除的事件监听。|
**示例:**
```js
inputMethodController.off('deleteLeft');
+```
+
+### off('deleteRight')10+
+
+off(type: 'deleteRight'): void
+
+取消订阅输入法应用向右删除文本事件。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | ------ | ---- | ------------------------------------------------------------ |
+| type | string | 是 | 设置监听类型。
- type为`deleteRight`表示取消订阅输入法应用向右删除的事件监听。|
+
+**示例:**
+
+```js
inputMethodController.off('deleteRight');
```
@@ -2110,11 +2155,11 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
inputMethodSetting.off('imeChange');
```
-### on('imeShow'|'imeHide')10+
+### on('imeShow')10+
-on(type: 'imeShow'|'imeHide', callback: (info: Array\) => void): void
+on(type: 'imeShow', callback: (info: Array\) => void): void
-订阅输入法软键盘显示或隐藏事件。使用callback异步回调。
+订阅输入法软键盘显示事件。使用callback异步回调。
**系统接口**:此接口为系统接口。
@@ -2124,7 +2169,7 @@ on(type: 'imeShow'|'imeHide', callback: (info: Array\) => void)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ---- |
-| type | string | 是 | 设置监听类型。
- type为`imeShow`时表示订阅输入法软键盘显示事件。
- type为`imeHide`时表示订阅输入法软键盘隐藏事件。 |
+| type | string | 是 | 设置监听类型。
- type为`imeShow`表示订阅输入法软键盘显示事件。 |
| callback | (info: Array\) => void | 是 | 回调函数,返回输入法软键盘信息。 |
**示例:**
@@ -2135,11 +2180,36 @@ inputMethodSetting.on('imeShow', (info) => {
});
```
-### off('imeShow'|'imeHide')10+
+### on('imeHide')10+
-off(type: 'imeShow'|'imeHide', callback?: (info: Array\) => void): void
+on(type: 'imeHide', callback: (info: Array\) => void): void
-取消订阅输入法软键盘显示或隐藏事件。
+订阅输入法软键盘隐藏事件。使用callback异步回调。
+
+**系统接口**:此接口为系统接口。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---- | ---- | ---- |
+| type | string | 是 | 设置监听类型。
- type为`imeHide`表示订阅输入法软键盘隐藏事件。 |
+| callback | (info: Array\) => void | 是 | 回调函数,返回输入法软键盘信息。 |
+
+**示例:**
+
+```js
+inputMethodSetting.on('imeHide', (info) => {
+ console.info('Succeeded in subscribing imeHide event.');
+});
+```
+
+### off('imeShow')10+
+
+off(type: 'imeShow', callback?: (info: Array\) => void): void
+
+取消订阅输入法软键盘显示事件。
**系统接口**:此接口为系统接口。
@@ -2149,7 +2219,7 @@ off(type: 'imeShow'|'imeHide', callback?: (info: Array\) => voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ------ |
-| type | string | 是 | 设置监听类型。
- type为`imeShow`时表示取消订阅输入法软键盘显示事件。
- type为`imeHide`时表示取消订阅输入法软键盘隐藏事件。 |
+| type | string | 是 | 设置监听类型。
- type为`imeShow`表示取消订阅输入法软键盘显示事件。 |
| callback | (info: Array\) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 |
**示例:**
@@ -2158,6 +2228,29 @@ off(type: 'imeShow'|'imeHide', callback?: (info: Array\) => voi
inputMethodSetting.off('imeShow');
```
+### off('imeHide')10+
+
+off(type: 'imeHide', callback?: (info: Array\) => void): void
+
+取消订阅输入法软键盘隐藏事件。
+
+**系统接口**:此接口为系统接口。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---- | ---- | ------ |
+| type | string | 是 | 设置监听类型。
- type为`imeHide`表示取消订阅输入法软键盘隐藏事件。 |
+| callback | (info: Array\) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 |
+
+**示例:**
+
+```js
+inputMethodSetting.off('imeHide');
+```
+
### listInputMethodSubtype9+
listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback<Array<InputMethodSubtype>>): void
diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
index f2394fa383e1ba947e3ea2a19d1d0d75884fe629..50c63eb10fed62b8d7ed71a52db48a7f2cdaaf09 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
@@ -1258,11 +1258,11 @@ promise.then(() => {
});
```
-### on10+
+### on('show')10+
-on(type: 'show' | 'hide', callback: () => void): void
+on(type: 'show', callback: () => void): void
-监听当前面板状态,使用callback异步回调。
+监听当前面板显示状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
@@ -1270,7 +1270,7 @@ on(type: 'show' | 'hide', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
-| type | 'show'\|'hide' | 是 | 监听当前面板的状态类型,show表示显示状态,hide表示隐藏状态 |
+| type | string | 是 | 监听当前面板的状态类型。
- type为`show`表示显示状态。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
@@ -1281,11 +1281,11 @@ panel.on('show', () => {
});
```
-### off10+
+### on('hide')10+
-off(type: 'show' | 'hide', callback?: () => void): void
+on(type: 'hide', callback: () => void): void
-取消监听当前面板状态,使用callback异步回调。
+监听当前面板隐藏状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
@@ -1293,7 +1293,30 @@ off(type: 'show' | 'hide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
-| type | 'show'\|'hide' | 是 | 要取消监听的当前面板状态类型,show表示显示状态,hide表示隐藏状态 |
+| type | string | 是 | 监听当前面板的状态类型。
- type为`hide`表示隐藏状态。 |
+| callback | () => void | 是 | 回调函数。 |
+
+**示例:**
+
+```js
+panel.on('hide', () => {
+ console.log('Panel is hiding.');
+});
+```
+
+### off('show')10+
+
+off(type: 'show', callback?: () => void): void
+
+取消监听当前面板显示状态,使用callback异步回调。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------- | ---- | -------- |
+| type | string | 是 | 要取消监听的当前面板状态类型。
- type为`show`表示显示状态。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
@@ -1302,6 +1325,27 @@ off(type: 'show' | 'hide', callback?: () => void): void
panel.off('show');
```
+### off('hide')10+
+
+off(type: 'hide', callback?: () => void): void
+
+取消监听当前面板隐藏状态,使用callback异步回调。
+
+**系统能力:** SystemCapability.MiscServices.InputMethodFramework
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ---------------------- | ---- | -------- |
+| type | string | 是 | 要取消监听的当前面板状态类型。
- type为`hide`表示隐藏状态。 |
+| callback | () => void | 否 | 回调函数。 |
+
+**示例:**
+
+```js
+panel.off('hide');
+```
+
### changeFlag10+
changeFlag(flag: PanelFlag): void
diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md
index 41e6e1d219d57be2fe2335d7872fb9b9e833bcba..b3b29c69c06b74a83ce6b42f8bce22588973e9ba 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-request.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-request.md
@@ -1888,11 +1888,11 @@ resume(callback: AsyncCallback<void>): void
| conf | [Conf](#conf10) | 是 | 任务的配置信息。 |
-### on('progress'|'completed'|'failed')10+
+### on('progress')10+
-on(event: "progress" | "completed" | "failed", callback: (progress: Progress) => void): void
+on(event: 'progress', callback: (progress: Progress) => void): void
-订阅任务相关的监听。
+订阅任务进度的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
@@ -1900,8 +1900,8 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | event | string | 是 | 订阅的事件类型。
- 取值为'progress',表示任务进度;
- 取值为'completed',表示任务已完成;
- 取值为'failed',表示任务失败。 |
- | callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
+ | event | string | 是 | 订阅的事件类型。
- 取值为'progress',表示任务进度。 |
+ | callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。|
**错误码:**
@@ -1950,7 +1950,149 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
};
request.agent.create(context, conf).then((task)=> {
task.on('progress', createOnCallback);
+ console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
+ }).catch((err) => {
+ console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
+ });
+ ```
+
+> **说明:**
+>
+> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
+
+### on('completed')10+
+
+on(event: 'completed', callback: (progress: Progress) => void): void
+
+订阅任务完成的监听。
+
+**系统能力**: SystemCapability.Request.FileTransferAgent
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | event | string | 是 | 订阅的事件类型。
- 取值为'completed',表示任务完成。 |
+ | callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
+
+**错误码:**
+
+以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。
+
+ | 错误码ID | 错误信息 |
+ | -------- | -------- |
+ | 21900005 | task mode error. |
+
+**示例:**
+
+ ```js
+ let context;
+ let attachments = [{
+ name: "taskOnTest",
+ value: {
+ filename: "taskOnTest.avi",
+ mimetype: "application/octet-stream",
+ path: "./taskOnTest.avi",
+ }
+ }];
+ let conf = {
+ action: request.agent.Action.UPLOAD,
+ url: 'http://127.0.0.1',
+ title: 'taskOnTest',
+ description: 'Sample code for event listening',
+ mode: request.agent.Mode.BACKGROUND,
+ overwrite: false,
+ method: "PUT",
+ data: attachments,
+ saveas: "./",
+ network: request.agent.Network.CELLULAR,
+ metered: false,
+ roaming: true,
+ retry: true,
+ redirect: true,
+ index: 0,
+ begins: 0,
+ ends: -1,
+ gauge: false,
+ precise: false,
+ token: "it is a secret"
+ };
+ let createOnCallback = (progress) => {
+ console.info('upload task completed.');
+ };
+ request.agent.create(context, conf).then((task)=> {
task.on('completed', createOnCallback);
+ console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
+ }).catch((err) => {
+ console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
+ });
+ ```
+
+> **说明:**
+>
+> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
+
+### on('failed')10+
+
+on(event: 'failed', callback: (progress: Progress) => void): void
+
+订阅任务失败的监听。
+
+**系统能力**: SystemCapability.Request.FileTransferAgent
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | event | string | 是 | 订阅的事件类型。
- 取值为'failed',表示任务失败。 |
+ | callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
+
+**错误码:**
+
+以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。
+
+ | 错误码ID | 错误信息 |
+ | -------- | -------- |
+ | 21900005 | task mode error. |
+
+**示例:**
+
+ ```js
+ let context;
+ let attachments = [{
+ name: "taskOnTest",
+ value: {
+ filename: "taskOnTest.avi",
+ mimetype: "application/octet-stream",
+ path: "./taskOnTest.avi",
+ }
+ }];
+ let conf = {
+ action: request.agent.Action.UPLOAD,
+ url: 'http://127.0.0.1',
+ title: 'taskOnTest',
+ description: 'Sample code for event listening',
+ mode: request.agent.Mode.BACKGROUND,
+ overwrite: false,
+ method: "PUT",
+ data: attachments,
+ saveas: "./",
+ network: request.agent.Network.CELLULAR,
+ metered: false,
+ roaming: true,
+ retry: true,
+ redirect: true,
+ index: 0,
+ begins: 0,
+ ends: -1,
+ gauge: false,
+ precise: false,
+ token: "it is a secret"
+ };
+ let createOnCallback = (progress) => {
+ console.info('upload task completed.');
+ };
+ request.agent.create(context, conf).then((task)=> {
task.on('failed', createOnCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
@@ -1962,11 +2104,12 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
-### off('progress'|'completed'|'failed')10+
-off(event: "progress" | "completed" | "failed", callback?: (progress: Progress) => void): void
+### off('progress')10+
+
+off(event: 'progress', callback?: (progress: Progress) => void): void
-取消订阅任务相关的监听。
+取消订阅任务进度的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
@@ -1974,8 +2117,8 @@ off(event: "progress" | "completed" | "failed", callback?: (progress: Progress)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | event | string | 是 | 订阅的事件类型。
- 取值为'progress',表示任务进度;
- 取值为'completed',表示任务已完成;
- 取值为'failed',表示任务失败。 |
- | callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
+ | event | string | 是 | 订阅的事件类型。
- 取值为'progress',表示任务进度。 |
+ | callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
**错误码:**
@@ -2024,10 +2167,152 @@ off(event: "progress" | "completed" | "failed", callback?: (progress: Progress)
};
request.agent.create(context, conf).then((task)=> {
task.on('progress', createOffCallback);
- task.on('completed', createOffCallback);
- task.on('failed', createOffCallback);
task.off('progress', createOffCallback);
+ console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
+ }).catch((err) => {
+ console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
+ });
+ ```
+
+> **说明:**
+>
+> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
+
+### off('completed')10+
+
+off(event: 'completed', callback?: (progress: Progress) => void): void
+
+取消订阅任务完成的监听。
+
+**系统能力**: SystemCapability.Request.FileTransferAgent
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | event | string | 是 | 订阅的事件类型。
- 取值为'completed',表示任务完成。 |
+ | callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
+
+**错误码:**
+
+以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。
+
+ | 错误码ID | 错误信息 |
+ | -------- | -------- |
+ | 21900005 | task mode error. |
+
+**示例:**
+
+ ```js
+ let context;
+ let attachments = [{
+ name: "taskOffTest",
+ value: {
+ filename: "taskOffTest.avi",
+ mimetype: "application/octet-stream",
+ path: "./taskOffTest.avi",
+ }
+ }];
+ let conf = {
+ action: request.agent.Action.UPLOAD,
+ url: 'http://127.0.0.1',
+ title: 'taskOffTest',
+ description: 'Sample code for event listening',
+ mode: request.agent.Mode.BACKGROUND,
+ overwrite: false,
+ method: "PUT",
+ data: attachments,
+ saveas: "./",
+ network: request.agent.Network.CELLULAR,
+ metered: false,
+ roaming: true,
+ retry: true,
+ redirect: true,
+ index: 0,
+ begins: 0,
+ ends: -1,
+ gauge: false,
+ precise: false,
+ token: "it is a secret"
+ };
+ let createOffCallback = (progress) => {
+ console.info('upload task completed.');
+ };
+ request.agent.create(context, conf).then((task)=> {
+ task.on('completed', createOffCallback);
task.off('completed', createOffCallback);
+ console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
+ }).catch((err) => {
+ console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
+ });
+ ```
+
+> **说明:**
+>
+> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
+
+### off('failed')10+
+
+off(event: 'failed', callback?: (progress: Progress) => void): void
+
+取消订阅任务失败的监听。
+
+**系统能力**: SystemCapability.Request.FileTransferAgent
+
+**参数:**
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | event | string | 是 | 订阅的事件类型。
- 取值为'failed',表示任务失败。 |
+ | callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
+
+**错误码:**
+
+以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。
+
+ | 错误码ID | 错误信息 |
+ | -------- | -------- |
+ | 21900005 | task mode error. |
+
+**示例:**
+
+ ```js
+ let context;
+ let attachments = [{
+ name: "taskOffTest",
+ value: {
+ filename: "taskOffTest.avi",
+ mimetype: "application/octet-stream",
+ path: "./taskOffTest.avi",
+ }
+ }];
+ let conf = {
+ action: request.agent.Action.UPLOAD,
+ url: 'http://127.0.0.1',
+ title: 'taskOffTest',
+ description: 'Sample code for event listening',
+ mode: request.agent.Mode.BACKGROUND,
+ overwrite: false,
+ method: "PUT",
+ data: attachments,
+ saveas: "./",
+ network: request.agent.Network.CELLULAR,
+ metered: false,
+ roaming: true,
+ retry: true,
+ redirect: true,
+ index: 0,
+ begins: 0,
+ ends: -1,
+ gauge: false,
+ precise: false,
+ token: "it is a secret"
+ };
+ let createOffCallback = (progress) => {
+ console.info('upload task completed.');
+ };
+ request.agent.create(context, conf).then((task)=> {
+ task.on('failed', createOffCallback);
task.off('failed', createOffCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
@@ -2053,7 +2338,7 @@ start(callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | callback | function | 是 | 回调函数,开启任务成功,err为undefined,否则为错误对象 |
+ | callback | function | 是 | 回调函数,开启任务成功,err为undefined,否则为错误对象。 |
**错误码:**
@@ -2187,7 +2472,7 @@ pause(callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | callback | function | 是 | 回调函数,暂停任务成功,err为undefined,否则为错误对象 |
+ | callback | function | 是 | 回调函数,暂停任务成功,err为undefined,否则为错误对象。 |
**错误码:**
@@ -2564,7 +2849,7 @@ stop(): Promise<void>
create(context: BaseContext, conf: Conf, callback: AsyncCallback<Task>): void
-创建要上传或下载的任务,并将其排入队列,使用callback异步回调。
+创建要上传或下载的任务,并将其排入队列,应用最多支持创建10个任务,服务承载的任务数最多为300个。使用callback异步回调。
**需要权限**:ohos.permission.INTERNET
@@ -2641,7 +2926,7 @@ create(context: BaseContext, conf: Conf, callback: AsyncCallback<Task>): v
create(context: BaseContext, conf: Conf): Promise<Task>
-创建要上传或下载的任务,并将其排入队列。使用Promise异步回调。
+创建要上传或下载的任务,并将其排入队列,应用最多支持创建10个任务,服务承载的任务数最多为300个。使用Promise异步回调。
**需要权限**:ohos.permission.INTERNET