HarmonyOS 使用minizip解压带密码的压缩包失败

HarmonyOS
2024-12-28 08:26:12
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

可以参考以下代码解压缩:

import fs from '@ohos.file.fs';
import { BusinessError } from '@kit.BasicServicesKit';
import { unzipToDirectory  } from '@ohos/minizip'

@Entry
@Component
struct Page {
  @State context:Context =getContext(this);

  build() {
    Column() {
      Row() {
        Button('jszip unzip testpwd').onClick(() => {
          const content = this.context.resourceManager.getRawFileContentSync("testpwd.zip");
          let file2 = fs.openSync(this.context.filesDir + '/testpwd.zip', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
          fs.writeSync(file2.fd, content.buffer);
          fs.close(file2);
          unzipToDirectory(this.context.filesDir + '/testpwd.zip', this.context.filesDir + '/unziptestpwd', '123456').then((result) => {
            console.log(result);
          }).catch((err: BusinessError) => {
            console.log(err.message);
          });
        })
      }
      .width('100%')
    }
    .height('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
分享
微博
QQ
微信
回复
2024-12-28 10:07:29
相关问题
如何解压密码压缩包
2572浏览 • 0回复 待解决
HarmonyOS支持解压加密压缩包吗?
873浏览 • 1回复 待解决
HarmonyOS gzip压缩解压缩接口
1462浏览 • 1回复 待解决
实现文件解压缩和数据流解压缩
2326浏览 • 1回复 待解决
HarmonyOS ZIP文件加密压缩解压缩
1709浏览 • 1回复 待解决
HarmonyOS 预置解压
685浏览 • 1回复 待解决
HarmonyOS 解压gzip格式压缩数据流
781浏览 • 1回复 待解决
HarmonyOS gzip二进制流压缩解压缩
1791浏览 • 1回复 待解决
HarmonyOS 图片压缩失败
736浏览 • 1回复 待解决
HarmonyOS 离线 下载解压
1542浏览 • 0回复 待解决
HarmonyOS如何解压GZIP压缩字符串?
1648浏览 • 1回复 待解决