HomeDocs
Skip to main content

FileSystemManager.unzip

Introduction​

Unzips a file.

Usage Restrictions​

Supported in Basic Library version 3.0.0 or higher.

Parameters​

Object object

PropertyTypeDefaultRequiredDescription
zipFilePathstringYesSource file path, supports relative path, must be a zip compressed file
targetPathstringYesTarget directory path, supports local path
successfunctionNoCallback function executed upon successful API call
failfunctionNoCallback function executed upon failed API call
completefunctionNoCallback function executed upon API call completion (executed regardless of success or failure)

object.success​

Callback Function

Parameters​

Object res​

PropertyTypeDescription
successstringtrue - successful setting

object.fail​

Callback Function

Parameters​

Object res​

PropertyTypeDescription
errMsgstringError message
successstringfalse - failed setting

errMsg Explanation

Error messageExplanation
parameter error: F10001Invalid parameter
fail sdcard not mounted: F10002Failed 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);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.