How to use react-native-zip-archive - 10 common examples

To help you get started, we’ve selected a few react-native-zip-archive examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mockingbot / react-native-zip-archive / example / Example.js View on Github external
return unlink(filePath).then(() => {
        // password for the dropbox sample zip file
        const password = 'helloworld'

        return zipWithPassword(
          filePath.split('.').slice(0, -1).join('.'),
          filePath,
          password
        ).then((response) => {
          console.log('Successfully archived the folder')
          console.log(response)
        }).catch((err) => {
          console.log(err)
        })
      }).catch((err) => {
        console.log(err)
github alphasp / pxview / src / components / UgoiraViewTouchable.js View on Github external
this.task = RNFetchBlob.config({
          fileCache: true,
          appendExt: 'zip',
          key: zipUrl,
          path: downloadPath,
        }).fetch('GET', zipUrl, {
          referer: 'http://www.pixiv.net',
        });
        try {
          this.setState({
            isDownloadingZip: true,
          });
          const res = await this.task;
          if (!this.unmounting) {
            try {
              const path = await unzip(res.path(), ugoiraPath);
              this.setState({
                ugoiraPath: path,
                isDownloadingZip: false,
              });
              // remove zip file after extracted
              res.flush();
            } catch (err) {
              this.setState({
                isDownloadingZip: false,
              });
            }
          }
        } catch (err) {
          this.setState({
            isDownloadingZip: false,
          });
github forest-watcher / forest-watcher / app / redux-modules / layers.js View on Github external
const { area, layerId, layerUrl, zoom } = config;
  const url = `${Config.API_URL}/download-tiles/${area.geostore.id}/${zoom.start}/${
    zoom.end
  }?layerUrl=${layerUrl}&useExtension=false`;
  const res = await RNFetchBlob.config({ fileCache: true })
    .fetch('GET', encodeURI(url))
    .progress((received, total) => {
      const progress = received / total;
      dispatch({ type: UPDATE_PROGRESS, payload: { areaId: area.id, progress, layerId } });
    });
  const statusCode = res.info().status;
  if (statusCode >= 200 && statusCode < 400 && res.path()) {
    const downloadPath = res.path();
    const tilesPath = `${CONSTANTS.files.tiles}/${area.id}/${layerId}`;
    const targetPath = `${RNFetchBlob.fs.dirs.DocumentDir}/${tilesPath}`;
    await unzip(downloadPath, targetPath);
    res.flush(); // remove from the cache
    return `${tilesPath}/{z}x{x}x{y}`;
  }
  throw new Error(`Fetch blob error ${statusCode}`);
}
github phodal / growth / src / containers / practises / leetcode / LeetCodeView.js View on Github external
unzipFiles(res) {
    unzip(res.path(), `${DIR.DocumentDir}`).then(() => {
      this.loadQuestionsToDB();
      AsyncStorageHelper.set('leetcode.unzip', 'true');
    }).catch((err) => {
      console.log(`解压失败 ${err}`);
      Toast.show(`解压失败 ${err}`);
    });
  }
github mockingbot / react-native-zip-archive / example / Example.js View on Github external
componentDidMount () {
    this.unzipProgress = subscribe(({ progress, filePath }) => {
      console.log('---- Progress update ----')
      console.log(filePath + ': ' + progress)
      console.log('-------------------------')
    })
  }
github mockingbot / react-native-zip-archive / example / Example.js View on Github external
}).then((isEncrypted) => {
      if (isEncrypted) {
        return unzipWithPassword(filePath, unzipPath, password)
      } else {
        return unzip(filePath, unzipPath)
      }
    }).then((response) => {
      console.log('Successfully unzipped files')
github guardian / editions / projects / Mallard / src / helpers / files.ts View on Github external
export const unzipNamedIssueArchive = (zipFilePath: string) => {
    const outputPath = FSPaths.issuesDir

    return unzip(zipFilePath, outputPath).then(() => {
        return RNFetchBlob.fs.unlink(zipFilePath)
    })
}
github BonnierNews / react-native-3d-model-view / lib / BaseModelView.js View on Github external
unzip (path) {
    return unzip(path, DOCUMENTS_FOLDER)
    .then(unzippedPath => {
      let name
      if (this.props.source.unzippedFolderName) {
        name = this.props.source.unzippedFolderName
      } else {
        name = this.getName(path)
        name = name.includes('.zip') ? name.replace('.zip', '') : name
      }
      return `${unzippedPath}/${name}`
    })
  }
github guardian / editions / projects / Apps / editionsSrc / src / helpers / files.ts View on Github external
export const unzipNamedIssueArchive = (zipFilePath: string) => {
    const outputPath = FSPaths.issuesDir

    return unzip(zipFilePath, outputPath).then(() => {
        return RNFetchBlob.fs.unlink(zipFilePath)
    })
}
github SkyzohKey / M-Droid / src / services / RepositoryService.js View on Github external
* - If it does exists, unzip it & parse the index-v1.json file inside.
       * - Else, parse the old index.xml file.
       */
      const repoUUID = RNFetchBlob.base64.encode(baseUrl).replace('=', '');
      const dlPath = RNFetchBlob.fs.dirs.DownloadDir + '/' + sanitizeUrl(baseUrl);

      const indexJarPath = dlPath + '/index-v1.jar';
      const responseV1 = await RNFetchBlob.config({ path: indexJarPath }).fetch(
        'GET',
        baseUrl + '/index-v1.jar'
      );

      let repoData = null;
      const exists = await RNFetchBlob.fs.exists(indexJarPath);
      if (exists && responseV1.info().status === 200) {
        const jsonPath = await unzip(indexJarPath, dlPath);
        const jsonData = await RNFetchBlob.fs.readFile(jsonPath + '/index-v1.json', 'utf8');

        repoData = parseRepoIndexV1(jsonData, repoUUID, baseUrl);
        await RNFetchBlob.fs.unlink(dlPath);
      } else {
        const response = await RNFetchBlob.fetch('GET', baseUrl + '/index.xml');
        const responseXml = await response.text();
        const doc = parser.parseFromString(responseXml);
        repoData = parseOldRepoIndex(doc, repoUUID, baseUrl);
      }

      if (repoData !== null) {
        cacheParsedRepo(baseUrl, repoData, CACHE_KEY);
        return { success: true, meta: repoData.meta, applications: repoData.applications };
      }
      return { success: false, error: 'Unknown error, cannot fetch repository ' + baseUrl };