HarmonyOS 解压压缩包报错BusinessError 17700101: Bundle manager service is excepted?

从服务器下载的压缩包,压缩包内的文件为截图

文件名为

main.android.js

vendor-manifest.json

vendor.android.js

每次解压均报错

BusinessError 17700101: Bundle manager service is excepted.

如何解决?

阅读 507
1 个回答

可以请从以下方面排查:

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}`);
    }
  })
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏