提交 30d0955f 编写于 作者: Z zhouzhichao

add js-apis-document.md

Signed-off-by: Nzhouzhichao <zhouzhichao3@huawei.com>
上级 67332246
......@@ -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)
......
# document
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**<br/>
> 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&lt;string&gt;
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&lt;string&gt; | URI of the file(Note: the current returned error code) |
- Example
```js
await document.choose(type);
```
## document.choose
choose(callback:AsyncCallback&lt;string&gt;): 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&lt;string&gt; | 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&lt;string&gt;): 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&lt;string&gt; | 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&lt;number&gt;
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&lt;void&gt; | 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&lt;void&gt;): 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&lt;void&gt; | 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
});
```
......@@ -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)
......
# document
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块接口后续将废弃。
## 导入模块
```js
import document from '@ohos.document';
```
## 使用说明
调用以下接口抛出异常,不建议在OpenHarmony使用以下接口。
## document.choose
choose(type:string[]): Promise&lt;string&gt;
通过文件管理器选择文件,异步返回文件URI,使用promise形式返回结果。
**系统能力**:SystemCapability.FileManagement.File.FileIO
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------- |
| type | string[] | 否 | 限定文件选择的类型 |
- 返回值:
| 类型 | 说明 |
| --------------------- | -------------- |
| Promise&lt;string&gt; | 异步返回文件URI(注:当前返回错误码) |
- 示例:
```js
await document.choose(type);
```
## document.choose
choose(callback:AsyncCallback&lt;string&gt;): void
通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。
**系统能力**:SystemCapability.FileManagement.File.FileIO
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步获取对应文件URI(注:当前返回错误码) |
- 示例:
```js
await document.choose(function(err, uri) {
//do something with uri
});
```
## document.choose
choose(type:string[], callback:AsyncCallback&lt;string&gt;): void
通过文件管理器选择文件,异步返回文件URI,使用callback形式返回结果。
**系统能力**:SystemCapability.FileManagement.File.FileIO
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | 否 | 限定选择文件的类型 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步获取对应文件URI(注:当前返回错误码) |
- 示例:
```js
await document.choose(type, function(err, uri) {
//do something with uri
});
```
## document.show
show(url:string, type:string):Promise&lt;number&gt;
异步打开URI对应的文件,使用promise形式返回结果。
**系统能力**:SystemCapability.FileManagement.File.FileIO
- 参数:
| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
| type | string | 是 | 待打开文件的类型 |
- 返回值:
| 类型 | 说明 |
| --------------------- | ------------ |
| Promise&lt;void&gt; | Promise回调返回void表示成功打开文件(注:当前返回错误码) |
- 示例:
```js
await document.show(uri, type);
```
## document.show
show(url:string, type:string, callback:AsyncCallback&lt;void&gt;): void
异步打开URI对应的文件,使用callback形式返回结果。
**系统能力**:SystemCapability.FileManagement.File.FileIO
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | 是 | 待打开的文件URI |
| type | string | 是 | 待打开文件的类型 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步打开uri对应文件(注:当前返回错误码) |
- 示例:
```js
await document.show(uri, type, function(err) {
//do something
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册