FileSystemManager.unzip
Introduction
Unzips a file.
Usage Restrictions
Supported in Basic Library version 3.0.0 or higher.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| zipFilePath | string | Yes | Source file path, supports relative path, must be a zip compressed file | |
| targetPath | string | Yes | Target directory path, supports local path | |
| success | function | No | Callback function executed upon successful API call | |
| fail | function | No | Callback function executed upon failed API call | |
| complete | function | No | Callback function executed upon API call completion (executed regardless of success or failure) |
object.success
Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| success | string | true - successful setting |
object.fail
Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| errMsg | string | Error message |
| success | string | false - failed setting |
errMsg Explanation
| Error message | Explanation |
|---|---|
| parameter error: F10001 | Invalid parameter |
| fail sdcard not mounted: F10002 | Failed to mount Android sdcard |
| fail permission denied: F10005, unzip ${zipFilePath} -> ${destPath} | No write permission for specified target file path |
| fail no such file or directory: F10007, unzip ${zipFilePath} -> ${destPath} | Source file does not exist, or the upper-level directory of the target file path does not exist |
Sample Code
// pages/index/index.js
Page({
unzip() {
const fs = dlt.getFileSystemManager();
fs.unzip({
zipFilePath: `${dlt.env.USER_DATA_PATH}/example.zip`,
targetPath: `${dlt.env.USER_DATA_PATH}/example`,
success(res) {
console.log(res);
},
fail(res) {
console.error(res);
},
});
},
});