Skip to content

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:

PropertyValue TypeRequiredDescription
filePathstringYesPath of the archive to read
encodingstringNoUniformly 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.
entriesstring/ArrayYesList of files inside the archive to read (passing "all" means reading all files inside the archive)
successfunctionNoCallback for a successful call
failfunctionNoCallback for a failed call
completefunctionNoCallback for when the call ends

Properties of entries array elements:

PropertyValue TypeRequiredDescription
pathstringYesFile path inside the archive
encodingstringNoSpecifies the character encoding for reading the file. If encoding is not passed, the binary content of the file is read in ArrayBuffer format.
positionnumberNoStart 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
lengthnumberNoSpecifies 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:

ValueDescription
asciiDecode as ASCII
base64Encode as a base64 string
binaryConvert unicode to a string
hexEncode as a hexadecimal string
ucs2 / ucs-2Read in little-endian order
utf16le / utf-16leRead in little-endian order
utf-8 / utf8Decode as UTF-8
latin1Convert unicode to a string

Parameters of the success callback

  • Object res: Returns the read result

res properties:

PropertyValue TypeDescription
entriesObjectFile 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:

PropertyValue TypeDescription
datastring/ArrayBufferFile content
errMsgstringError information

Parameters of the fail callback

  • Object res: Returns error information

res properties:

PropertyValue TypeDescription
errMsgstringError information