反应本机android错误:org.apache.commons.compress.compressors.CompressorException:无法创建CompressorInputStream

问题描述

我正在使用react-native-archiver提取tar文件

   const targetPath = ExternalDirectoryPath;
   RNArchiver.untar(ExternalDirectoryPath + '/content.tar',targetPath)
     .then(path => {
       console.log(`untar completed at ${path}`)
     })
     .catch(error => {
       console.error(error)
     })

我在android上遇到此错误

Error: org.apache.commons.compress.compressors.CompressorException: Could not create CompressorInputStream.

解决方法

我设法通过更改节点模块内部的RNArchiverModule.java中的这一行代码来解决此问题-> react-native-archiver-> android

发件人:

Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR,CompressionType.GZIP); 

收件人:

 Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR);

是提取tar.gz而不是tar。

但是图书馆仍然不支持ios,我需要为此找到解决方案吗?