choose(types?: string[]): Promise<string>
Chooses files of the specified types. This API uses a promise to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| types | string[] | No | Types of the files to choose. |
Return value
| Type | Description |
|---|---|
| Promise<string> | Promise used to return the result. An error code is returned. |
Example
let types: Array<string> = []; document.choose(types);
choose(callback:AsyncCallback<string>): void
Chooses a file. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. |
Example
let uri: string = "";
document.choose((err: TypeError, uri: string) => {
// Do something with the URI.
}); choose(types:string[], callback:AsyncCallback<string>): void
Chooses files of the specified types. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| types | string[] | Yes | Types of the files to choose. |
| callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned. |
Example
let types: Array<string> = [];
let uri: string = "";
document.choose(types, (err: TypeError, uri: string) => {
// Do something with the URI.
}); show(uri:string, type:string):Promise<void>
Opens a file. This API uses a promise to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
Return value
| Type | Description |
|---|---|
| Promise<void> | Promise used to return the result. An error code is returned. |
Example
let type: string = ""; let uri: string = ""; document.show(uri, type);
show(uri:string, type:string, callback:AsyncCallback<void>): void
Opens a file. This API uses an asynchronous callback to return the result.
System capability: SystemCapability.FileManagement.UserFileService
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. |
Example
let type: string = "";
let uri: string = "";
document.show(uri, type, (err: TypeError) => {
//do something
});