FileSystemManager.readZipEntry
JS
FileSystemManager.readZipEntry(Object object)Reads files inside an archive
Parameters
- Object object: Input parameters. See the table below for details.
object properties:
| Property | Value Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Path of the archive to read |
| encoding | string | No | Uniformly specifies the character encoding for reading files. Only effective when entries is "all". If entries is "all" and encoding is not passed, the binary content of the files is read in ArrayBuffer format. |
| entries | string/Array | Yes | List of files inside the archive to read (passing "all" means reading all files inside the archive) |
| 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 |
Properties of entries array elements:
| Property | Value Type | Required | Description |
|---|---|---|---|
| path | string | Yes | File path inside the archive |
| encoding | string | No | Specifies the character encoding for reading the file. If encoding is not passed, the binary content of the file is read in ArrayBuffer format. |
| 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 |
Valid values of encoding:
| Value | Description |
|---|---|
| ascii | Decode as ASCII |
| base64 | Encode as a base64 string |
| binary | Convert unicode to a string |
| hex | Encode as a hexadecimal string |
| ucs2 / ucs-2 | Read in little-endian order |
| utf16le / utf-16le | Read in little-endian order |
| utf-8 / utf8 | Decode as UTF-8 |
| latin1 | Convert unicode to a string |
Parameters of the success callback
- Object res: Returns the read result
res properties:
| Property | Value Type | Description |
|---|---|---|
| entries | Object | File read results. res.entries is an object where the key is the file path and the value is a FileItem object representing the read result of that file. Each FileItem contains data (file content) and errMsg (error information) properties. |
FileItem properties:
| Property | Value Type | Description |
|---|---|---|
| data | string/ArrayBuffer | File content |
| errMsg | string | Error information |
Parameters of the fail callback
- Object res: Returns error information
res properties:
| Property | Value Type | Description |
|---|---|---|
| errMsg | string | Error information |
