提交 e54f237a 编写于 作者: Z zhouzhichao

add js-apis-document.md

Signed-off-by: Nzhouzhichao <zhouzhichao3@huawei.com>
上级 9a891c97
......@@ -118,7 +118,6 @@
- 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 initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
- The interface of this module will be discarded later.Calling the following interface throws an exception. It is not recommended to use the following interface in OpenHarmony.
## Modules to Import
```js
import document from '@ohos.document';
```
## 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
});
```
# document
# 文件交互
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
- 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册