• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.document (File Interaction)
2
3> **NOTE**<br/>
4> - 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.
5> - The APIs of this module have been deprecated since API version 9 and are not recommended for use. An exception will be thrown if any of the APIs is called.
6
7## Modules to Import
8
9```js
10import document from '@ohos.document';
11```
12
13## document.choose<sup>(deprecated)</sup>
14
15choose(types? : string[]): Promise&lt;string&gt;
16
17Chooses files of the specified types using the file manager. This API uses a promise to return the result.
18
19**System capability**: SystemCapability.FileManagement.UserFileService
20
21**Parameters**
22
23  | Name| Type  | Mandatory| Description                        |
24  | ------ | ------ | ---- | ---------------------------- |
25  | types   | string[] | No  | Types of the files to choose.|
26
27**Return value**
28
29  | Type                 | Description          |
30  | --------------------- | -------------- |
31  | Promise&lt;string&gt; | Promise used to return the result. An error code is returned.|
32
33**Example**
34
35  ```js
36  let types = [];
37  document.choose(types);
38  ```
39## document.choose<sup>(deprecated)</sup>
40
41choose(callback:AsyncCallback&lt;string&gt;): void
42
43Chooses a file using the file manager. This API uses an asynchronous callback to return the result.
44
45**System capability**: SystemCapability.FileManagement.UserFileService
46
47**Parameters**
48
49  | Name  | Type                       | Mandatory| Description                        |
50  | -------- | --------------------------- | ---- | ---------------------------- |
51  | callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result. An error code is returned.|
52
53**Example**
54
55  ```js
56  let uri = "";
57  document.choose(function(err, uri) {
58        // Do something with the URI.
59  });
60  ```
61## document.choose<sup>(deprecated)</sup>
62
63choose(types:string[], callback:AsyncCallback&lt;string&gt;): void
64
65Chooses files using the file manager. This API uses an asynchronous callback to return the result.
66
67**System capability**: SystemCapability.FileManagement.UserFileService
68
69**Parameters**
70
71  | Name  | Type                       | Mandatory| Description                        |
72  | -------- | --------------------------- | ---- | ---------------------------- |
73  | types    | string[]                      | No  | Types of the files to choose.|
74  | callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result. An error code is returned.|
75
76**Example**
77
78  ```js
79  let types = [];
80  let uri = "";
81  document.choose(types, function(err, uri) {
82        // Do something with the URI.
83  });
84  ```
85
86## document.show<sup>(deprecated)</sup>
87
88show(uri:string, type:string):Promise&lt;void&gt;
89
90Opens a file. This API uses a promise to return the result.
91
92**System capability**: SystemCapability.FileManagement.UserFileService
93
94**Parameters**
95
96  | Name| Type  | Mandatory| Description                        |
97  | ---- | ------ | ---- | ---------------------------- |
98  | uri | string | Yes  | URI of the file to open.|
99  | type | string | Yes  | Type of the file to open.|
100
101**Return value**
102
103  | Type                 | Description        |
104  | --------------------- | ------------ |
105  | Promise&lt;void&gt; | Promise used to return the result. An error code is returned.|
106
107**Example**
108
109  ```js
110  let type = "";
111  let uri = "";
112  document.show(uri, type);
113  ```
114
115## document.show<sup>(deprecated)</sup>
116
117show(uri:string, type:string, callback:AsyncCallback&lt;void&gt;): void
118
119Opens a file. This API uses an asynchronous callback to return the result.
120
121**System capability**: SystemCapability.FileManagement.UserFileService
122
123**Parameters**
124
125  | Name  | Type                       | Mandatory| Description                        |
126  | -------- | --------------------------- | ---- | ---------------------------- |
127  | uri | string | Yes  | URI of the file to open.|
128  | type | string | Yes  | Type of the file to open.|
129  | callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. An error code is returned.  |
130
131**Example**
132
133  ```js
134  let type = "";
135  let uri = "";
136  document.show(uri, type, function(err) {
137        //do something
138  });
139  ```
140