HarmonyOS 鸿蒙Next 解压压缩包报错BusinessError 17700101 Bundle manager service is excepted
HarmonyOS 鸿蒙Next 解压压缩包报错BusinessError 17700101 Bundle manager service is excepted
HarmonyOS 解压压缩包报错BusinessError 17700101: Bundle manager service is excepted?
2 回复
可以请从以下方面排查:
1.检查文件完整性,如果是在线文件请是否下载完成
2是文件名里带有一些特殊符号所以解压失败了(压缩包里存在名字包含“~”等字符的文件可能会导致解压失败,把它从压缩包里移除即可)
解压可以参考下述demo:
// 参考demo如下可以实现成功解压
function zlibDecompress() {
getContext().resourceManager.getRawFileContent('miniprogram2.zip', (_err, value) => {
let myBuffer:ArrayBufferLike = value.buffer
let context = getContext();
//沙箱路径
let filePath = context.filesDir + "/miniprogram2.zip";
console.log("testTag-filePath:" + filePath);
let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let writeLen = fs.writeSync(file.fd, myBuffer);
console.info("testTag-write data to file succeed and size is:" + writeLen);
fs.closeSync(file);
let inFile = getContext().filesDir + "/miniprogram2.zip";
let outFileDir = getContext().filesDir;
let options: zlib.Options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION
};
try {
zlib.decompressFile(inFile, outFileDir, options, (errData: BusinessError) => {
if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}
})
} catch(errData) {
let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
}
})
}