未验证 提交 66ceaadb 编写于 作者: O openharmony_ci 提交者: Gitee

!5602 【翻译完成】#I5CCR5

Merge pull request !5602 from Annie_wang/PR5207
...@@ -63,13 +63,19 @@ Obtains information about the root album or directory in asynchronous mode. This ...@@ -63,13 +63,19 @@ Obtains information about the root album or directory in asynchronous mode. This
- Example - Example
```js ```js
filemanager.getRoot((err, fileInfo) => { let option = {
"dev":{
name:"",
}
};
filemanager.getRoot(option,(err, fileInfo)=>{
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) { for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo)); console.log("file:"+JSON.stringify(fileInfo));
} }
} }
}); });
``` ```
## filemanager.listFile ## filemanager.listFile
...@@ -105,7 +111,7 @@ Obtains information about the second-level album or files in asynchronous mode. ...@@ -105,7 +111,7 @@ Obtains information about the second-level album or files in asynchronous mode.
```js ```js
// Obtain all files in the directory. // Obtain all files in the directory.
// Call listFile() and getRoot() to obtain the file URI. // Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri let media_path = file.path
filemanager.listFile(media_path, "file") filemanager.listFile(media_path, "file")
.then((fileInfo) => { .then((fileInfo) => {
if(Array.isArray(fileInfo)) { if(Array.isArray(fileInfo)) {
...@@ -114,10 +120,13 @@ Obtains information about the second-level album or files in asynchronous mode. ...@@ -114,10 +120,13 @@ Obtains information about the second-level album or files in asynchronous mode.
} }
} }
}).catch((err) => { }).catch((err) => {
console.log(err)
}); console.log(err)
});
``` ```
## filemanager.listFile ## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
...@@ -130,8 +139,8 @@ Obtains information about the second-level album or files in asynchronous mode. ...@@ -130,8 +139,8 @@ Obtains information about the second-level album or files in asynchronous mode.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | URI of the directory to query. | | path | string | Yes | URI of the directory to query. |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.| | type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. | | callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
- Error - Error
...@@ -145,14 +154,30 @@ Obtains information about the second-level album or files in asynchronous mode. ...@@ -145,14 +154,30 @@ Obtains information about the second-level album or files in asynchronous mode.
- Example - Example
```js ```js
// Call listFile() and getRoot() to obtain the file URI. // Call listFile() and getRoot() to obtain the file path.
let media_path = file.uri let fileInfos = await filemanager.getRoot();
filemanager.listFile(media_path, "file", (err, fileInfo) => { let media_path = "";
if(Array.isArray(fileInfo)) { for (let i = 0; i < fileInfos.length; i++) {
for (var i = 0; i < fileInfo.length; i++) { if (fileInfos[i].name == "image_album") {
console.log("file:"+JSON.stringify(fileInfo)); media_path = fileInfos[i].path;
} } else if (fileInfos[i].name == "audio_album") {
} media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "video_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "file_folder") {
media_path = fileInfos[i].path;
}
}
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
}).catch((err) => {
console.log(err)
}); });
``` ```
...@@ -211,8 +236,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb ...@@ -211,8 +236,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- | | -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | Yes | Name of the file to create. | | filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. | | path | string | Yes | URI of the file to create. |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.| | options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. | | callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
...@@ -230,7 +255,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb ...@@ -230,7 +255,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
```js ```js
// Create a file. // Create a file.
// Call listFile() and getRoot() to obtain the file URI. // Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri let media_path = file.path
// File to be saved. // File to be saved.
let name = "xxx.jpg" let name = "xxx.jpg"
filemanager.createFile(media_path, name, (err, uri) => { filemanager.createFile(media_path, name, (err, uri) => {
......
# statfs # statfs
> **NOTE**<br> > **NOTE:**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
This module provides information related to the file system. It provides JS APIs to obtain the total number of bytes and the number of idle bytes of the file system. Obtains file system information, including the total number of bytes and the number of idle bytes of the file system.
## Modules to Import ## Modules to Import
```js ```js
import statfs from '@ohos.statfs'; import statfs from '@ohos.statfs';
``` ```
## Guidelines
Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md).
Application sandbox path of a file or directory = Application directory + File name or directory name
For example, if the application directory obtained by using **getOrCreateLocalDir** is **dir** and the file name is **xxx.txt**, the application sandbox path of the file is as follows:
```js
let path = dir + "xxx.txt";
```
## statfs.getFreeBytes ## statfs.getFreeBytes
getFreeBytes(path:string):Promise&lt;number&gt; getFreeBytes(path:string):Promise&lt;number&gt;
...@@ -72,8 +59,12 @@ Obtains the number of free bytes of the specified file system in asynchronous mo ...@@ -72,8 +59,12 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
- Example - Example
```js ```js
statfs.getFreeBytes(path, function(err, number){ import featureAbility from '@ohos.ability.featureAbility';
console.info("getFreeBytes callback successfully:"+ number); let context = featureAbility.getContext();
context.getFilesDir().then(function (path) {
statfs.getFreeBytes(path, function(err, number){
console.info("getFreeBytes callback successfully:"+ number);
});
}); });
``` ```
...@@ -126,7 +117,11 @@ Obtains the total number of bytes of the specified file system in asynchronous m ...@@ -126,7 +117,11 @@ Obtains the total number of bytes of the specified file system in asynchronous m
- Example - Example
```js ```js
statfs.getTotalBytes(path, function(err, number){ import featureAbility from '@ohos.ability.featureAbility';
console.info("getTotalBytes callback successfully:"+ number); let context = featureAbility.getContext();
context.getFilesDir().then(function (path) {
statfs.getTotalBytes(path, function(err, number){
console.info("getTotalBytes callback successfully:"+ number);
});
}); });
``` ```
...@@ -25,11 +25,11 @@ Encrypts or decrypts data using RSA. ...@@ -25,11 +25,11 @@ Encrypts or decrypts data using RSA.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| action | string | Yes| Action to perform. The options are as follows:<br>-&nbsp;encrypt<br>-&nbsp;decrypt| | action | string | Yes| Action to perform. The options are as follows:<br>-&nbsp;encrypt<br/>-&nbsp;decrypt|
| text | string | Yes| Text to be encrypted or decrypted.<br> The text to be encrypted must be common text that meets the following requirement:<br> Maximum text length = Key length/8 - 66<br>For example, if the key is of 1024 bytes, the text to be encrypted cannot exceed 62 bytes (1024/8 -66 = 62).<br> The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | text | string | Yes| Text to be encrypted or decrypted.<br> The text to be encrypted must be common text that meets the following requirement:<br> Maximum text length = Key length/8 - 66<br>For example, if the key is of 1024 bytes, the text to be encrypted cannot exceed 62 bytes (1024/8 -66 = 62).<br> The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.|
| key | string | Yes| RSA key. The key is used as a public key in encryption and a private key in decryption.| | key | string | Yes| RSA key. The key is used as a public key in encryption and a private key in decryption.|
| transformation | string | No| RSA padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**.| | transformation | string | No| RSA padding. The default value is **RSA/None/OAEPWithSHA256AndMGF1Padding**.|
| success | Function | No| Called when data is encrypted or decrypted successful.| | success | Function | No| Called when data is encrypted or decrypted successfully.|
| fail | Function | No| Called when data fails to be encrypted or decrypted.| | fail | Function | No| Called when data fails to be encrypted or decrypted.|
| complete | Function | No| Called when the execution is complete.| | complete | Function | No| Called when the execution is complete.|
...@@ -104,14 +104,14 @@ Encrypts or decrypts data using AES. ...@@ -104,14 +104,14 @@ Encrypts or decrypts data using AES.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| action | string | Yes| Action to perform. The options are as follows:<br>-&nbsp;encrypt<br>-&nbsp;decrypt| | action | string | Yes| Action to perform. The options are as follows:<br>-&nbsp;encrypt<br/>-&nbsp;decrypt|
| text | string | Yes| Text to be encrypted or decrypted.<br> The text to be encrypted must be common text. The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.| | text | string | Yes| Text to be encrypted or decrypted.<br> The text to be encrypted must be common text. The text to be decrypted must be binary text encoded in Base64. The default format is used for Base64 encoding.|
| key | string | Yes| Key used for encryption or decryption. It is a string encoded in Base64.| | key | string | Yes| Key used for encryption or decryption. It is a string encoded in Base64.|
| transformation | string | No| Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**.| | transformation | string | No| Encryption mode and padding of the AES algorithm. The default value is **AES/CBC/PKCS5Padding**.|
| iv | string | No| Initialization vector (IV) for AES-based encryption and decryption. The value is a string encoded in Base64. The default value is the key value.| | iv | string | No| Initialization vector (IV) for AES-based encryption and decryption. The value is a string encoded in Base64. The default value is the key value.|
| ivOffset | string | No| Offset of the IV for AES-based encryption and decryption. The default value is **0**.| | ivOffset | string | No| Offset of the IV for AES-based encryption and decryption. The default value is **0**.|
| ivLen | string | No| Length of the IV for AES-based encryption and decryption, in bytes. The default value is **16**.| | ivLen | string | No| Length of the IV for AES-based encryption and decryption, in bytes. The default value is **16**.|
| success | Function | No| Called when data is encrypted or decrypted successful.| | success | Function | No| Called when data is encrypted or decrypted successfully.|
| fail | Function | No| Called when data fails to be encrypted or decrypted.| | fail | Function | No| Called when data fails to be encrypted or decrypted.|
| complete | Function | No| Called when the execution is complete.| | complete | Function | No| Called when the execution is complete.|
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable. > - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
This module provides APIs to implement volume and disk management, including obtaining volume information, mounting and unmounting volumes, partitioning disks, and formatting volumes. Performs volume and disk management, including obtaining volume information, mounting and unmounting volumes, partitioning disks, and formatting volumes.
## Modules to Import ## Modules to Import
...@@ -54,7 +54,7 @@ Asynchronously obtains information about all available volumes. This API uses a ...@@ -54,7 +54,7 @@ Asynchronously obtains information about all available volumes. This API uses a
```js ```js
let uuid = ""; let uuid = "";
volumemanager.getAllVolumes(uuid, function(error, volumes){ volumemanager.getAllVolumes(function(error, volumes){
// do something // do something
}); });
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册