title: FileSystemManager.unzip header: develop nav: api

sidebar: FileSystemManager-unzip

解释:解压文件。

方法参数:Object object

object参数说明

参数名 类型 必填 默认值 说明
zipFilePath String - 源文件路径,必须是 zip 压缩文件
targetPath String - 解压目标路径,目标目录必须位于用户目录下
success Function - 接口调用成功的回调函数
fail Function - 接口调用失败的回调函数
complete Function - 接口调用结束的回调函数(调用成功、失败都会执行)

代码示例

  • 在 js 文件中
  1. Page({
  2. onLoad() {
  3. const fs = swan.getFileSystemManager();
  4. this.fs = fs;
  5. },
  6. unzip() {
  7. this.fs.unzip({
  8. zipFilePath: `${swan.env.USER_DATA_PATH}/demo/a.zip`,
  9. targetPath: `${swan.env.USER_DATA_PATH}/demo/b`,
  10. success: res => {
  11. console.log('unzip success', res);
  12. },
  13. fail: err => {
  14. console.log('unzip fail', err)
  15. }
  16. });
  17. }
  18. });