FileSystemManager.readFile
Requires:
BaseKit≥2.0.1
Platforms:
iOSAndroid
Method signature
FileSystemManager.readFile(params: )Description
Read the contents of a local file
Parameters
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
filePath | string | Yes | - | File path to read (local path) |
encoding | string | No | "utf8" | Specify the character encoding for reading the file. Supports utf8/ascii/base64. If encoding is not provided, defaults to utf8. |
position | number | No | - | Read starting from the specified position in the file; if not specified, start from the beginning. The read range is [position, position+length) (left-closed, right-open). Valid range: [0, fileLength - 1]. Unit: byte |
length | number | No | - | Specify the length to read; if not specified, read to the end of the file. Valid range: [1, fileLength]. Unit: byte |
complete | () => void | No | - | Completion callback (executed on both success and failure) |
success | (params: Object) => void | No | - | Callback on successful API call |
fail | (params: Object) => void | No | - | Failure callback |
success callback parameters
| Property | Type | Description | Since |
|---|---|---|---|
data | string | File content | v3.2.6 |
fail callback parameters
| Property | Type | Description |
|---|---|---|
errorMsg | string | Error message |
errorCode | string | number | Error code |
| Error extension |
Return Value
None