FileSystemManager.readFile
JS
FileSystemManager.readFile(Object object)Reads the content of a local file
Parameters
- Object object: Input parameters. See the table below for details.
object properties:
| Property | Value Type | Default | Required | Description |
|---|---|---|---|---|
| filePath | string | Yes | Path of the file to read | |
| encoding | string | binary | No | Specifies the character encoding for reading the file. See the figure below for valid values. |
| position | number | No | Start reading from the specified position in the file. If not specified, reading starts from the beginning of the file. The read range is the left-closed, right-open interval [position, position+length). Valid range: [0, fileLength - 1]. Unit: byte | |
| length | number | No | Specifies the length of the file to read. If not specified, reading continues to the end of the file. Valid range: [1, fileLength]. Unit: byte | |
| success | function | No | Callback for a successful call | |
| fail | function | No | Callback for a failed call | |
| complete | function | No | Callback for when the call ends |
Valid values of encoding:
| Value | Description |
|---|---|
| utf8 | utf-8 encoding |
| utf-8 | utf-8 encoding |
| binary | Binary |
Parameters of the success callback
- Object res: Returns file information
res properties:
| Property | Value Type | Description |
|---|---|---|
| data | string/ArrayBuffer | File content |
