From ae58917c41680a75f592c4bd6c44263039e83e6b Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 28 Apr 2022 11:31:07 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 1 + .../reference/apis/js-apis-document.md | 130 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-document.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index ca23a3f1ea..f62fac0875 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -119,6 +119,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 0000000000..0f2de0b217 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-document.md @@ -0,0 +1,130 @@ +# File Interaction + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+- 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 APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called. +## Modules to Import + +```js +import document from '@ohos.document'; +``` + +## document.choose + +choose(type:string[]): Promise<string> + +Chooses a file of the specified type using the file manager. This method uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name| Type | Mandatory| Description | + | ------ | ------ | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose.| + +- Return value + + | Type | Description | + | --------------------- | -------------- | + | Promise<string> | Promise used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(type); + ``` +## document.choose + +choose(callback:AsyncCallback<string>): void + +Chooses a file using the file manager. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(function(err, uri) { + // Do something with the URI. + }); + ``` +## document.choose + +choose(type:string[], callback:AsyncCallback<string>): void + +Chooses a file of the specified type using the file manager. This method uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.File.FileIO + +- Parameters + + | Name | Type | Mandatory| Description | + | -------- | --------------------------- | ---- | ---------------------------- | + | type | string[] | No | Type of the file to choose.| + | callback | AsyncCallback<string> | Yes | Callback used to return the result. An error code is returned.| + +- Example + + ```js + await document.choose(type, function(err, uri) { + // Do something with the URI. + }); + ``` + +## document.show + +show(url:string, type:string):Promise<number> + +Opens a file. This method uses a promise to return the result. + +**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 to open.| + +- Return value + + | Type | Description | + | --------------------- | ------------ | + | Promise<void> | Promise used to return the result. An error code is returned.| + +- Example + + ```js + await document.show(uri, type); + ``` + +## document.show + +show(url:string, type:string, callback:AsyncCallback<void>): void + +Opens a file. This method uses an asynchronous callback to return the result. + +**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 to open.| + | callback | AsyncCallback<void> | Yes | Callback used to return the result. An error code is returned. | + +- Example + + ```js + await document.show(uri, type, function(err) { + //do something + }); + ``` -- GitLab