diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index fdf237a4b1c488e67c674ec0761329d46f043b7d..0ff5001212bf448678e77412d2cc4fdc9712c735 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -118,6 +118,7 @@ - File Management + - [@ohos.document](js-apis-document.md) - [@ohos.environment](js-apis-environment.md) - [@ohos.fileio](js-apis-fileio.md) - [@ohos.fileManager](js-apis-filemanager.md) diff --git a/en/application-dev/reference/apis/js-apis-document.md b/en/application-dev/reference/apis/js-apis-document.md new file mode 100644 index 0000000000000000000000000000000000000000..590d2cff07211bc7e52f169d13b8e4ad99d60d9f --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -0,0 +1,135 @@ +# document + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
+> The interface of this module will be discarded later. + +## Modules to Import + +```js +import document from '@ohos.document'; +``` + +## Guidelines + +Using this function module will throw an error code. + +## document.choose + +choose(type:string[]): Promise<string> + +Selects a file using the file manager and returns the file URI asynchronously using a promise. + +**System capability**:SystemCapability.FileManagement.File.FileIO + +- **Parameters** + +| Name | Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | No | Type of the file selected. | + +- Return value + + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | URI of the file(Note: the current returned error code) | + +- Example + + ```js + await document.choose(type); + ``` +## document.choose + +choose(callback:AsyncCallback<string>): void + +Selects a file using the file manager and returns the file URI using an asynchronous callback. + +**System capability**:SystemCapability.FileManagement.File.FileIO + +- **Parameters** + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to obtain the URI of the file asynchronously(Note: the current returned error code) | + +- Example + + ```js + await document.choose(function(err, uri) { + //do something with uri + }); + ``` +## document.choose + +choose(type:string[], callback:AsyncCallback<string>): void + +Selects a file using the file manager and returns the file URI using an asynchronous callback. + +**System capability**:SystemCapability.FileManagement.File.FileIO + +- **Parameters** + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | No | Type of the file selected. | + | callback | AsyncCallback<string> | Yes | Callback used to obtain the URI of the file asynchronously(Note: the current returned error code) | + +- Example + + ```js + await document.choose(type, function(err, uri) { + //do something with uri + }); + ``` + +## document.show + +show(url:string, type:string):Promise<number> + +Asynchronously opens the file corresponding to the URI and returns the result using a promise. + +**System capability**:SystemCapability.FileManagement.File.FileIO + +- **Parameters** + + | Name | Type | Mandatory| Description | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open | + | type | string | Yes | Type of the file. Currently | + +- Return value + + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Returns void if the file is open successfully(Note: the current returned error code) | + +- Example + + ```js + await document.show(uri, type); + ``` + +## document.show + +show(url:string, type:string, callback:AsyncCallback<void>): void + +Asynchronously opens the file corresponding to the URI and returns the result using a callback. + +**System capability**:SystemCapability.FileManagement.File.FileIO + +- **Parameters** + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | Yes | URI of the file to open| + | type | string | Yes | Type of the file. Currently | + | callback | AsyncCallback<void> | Yes | Asynchronous callback used to open the file corresponding to the URI(Note: the current returned error code) | + +- Example + + ```js + await document.show(uri, type, function(err) { + //do something + }); + ``` + diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index ba64727c42ae62aaacbff33193ac6339c1e3c196..767691f37da8ecf753b311ad04101327e96538f1 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -118,6 +118,7 @@ - 文件管理 + - [@ohos.document (文件交互)](js-apis-document.md) - [@ohos.environment (目录环境能力)](js-apis-environment.md) - [@ohos.fileio (文件管理)](js-apis-fileio.md) - [@ohos.fileManager (公共文件访问与管理)](js-apis-filemanager.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-document.md b/zh-cn/application-dev/reference/apis/js-apis-document.md new file mode 100644 index 0000000000000000000000000000000000000000..b8aa1fc2800f71091682d9281a310bce45ed02bf --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-document.md @@ -0,0 +1,135 @@ +# document + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块接口后续将废弃。 + +## 导入模块 + +```js +import document from '@ohos.document'; +``` + +## 使用说明 + +调用以下接口抛出异常,不建议在OpenHarmony使用以下接口。 + +## document.choose + +choose(type:string[]): Promise<string> + +通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | 否 | 限定文件选择的类型 | + +- 返回值: + + | 类型 | 说明 | + | --------------------- | -------------- | + | Promise<string> | 异步返回文件URI(注:当前返回错误码) | + +- 示例: + + ```js + await document.choose(type); + ``` +## document.choose + +choose(callback:AsyncCallback<string>): void + +通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) | + +- 示例: + + ```js + await document.choose(function(err, uri) { + //do something with uri + }); + ``` +## document.choose + +choose(type:string[], callback:AsyncCallback<string>): void + +通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | 否 | 限定选择文件的类型 | + | callback | AsyncCallback<string> | 是 | 异步获取对应文件URI(注:当前返回错误码) | + +- 示例: + + ```js + await document.choose(type, function(err, uri) { + //do something with uri + }); + ``` + +## document.show + +show(url:string, type:string):Promise<number> + +异步打开URI对应的文件,使用promise形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +- 参数: + + | 参数 | 类型 | 必填 | 说明 | + | ---- | ------ | ---- | ---------------------------- | + | uri | string | 是 | 待打开的文件URI | + | type | string | 是 | 待打开文件的类型 | + +- 返回值: + + | 类型 | 说明 | + | --------------------- | ------------ | + | Promise<void> | Promise回调返回void表示成功打开文件(注:当前返回错误码) | + +- 示例: + + ```js + await document.show(uri, type); + ``` + +## document.show + +show(url:string, type:string, callback:AsyncCallback<void>): void + +异步打开URI对应的文件,使用callback形式返回结果。 + +**系统能力**:SystemCapability.FileManagement.File.FileIO + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------- | ---- | ---------------------------- | + | uri | string | 是 | 待打开的文件URI | + | type | string | 是 | 待打开文件的类型 | + | callback | AsyncCallback<void> | 是 | 异步打开uri对应文件(注:当前返回错误码) | + +- 示例: + + ```js + await document.show(uri, type, function(err) { + //do something + }); + ``` +