所以问题很简单。我有一个 zip 文件的 url。我需要下载它并从中提取 csv 文件。 csv 中的值将保存到数组中。
我找到了 this stackoverflow threat但它使用 adm-zip,它与节点的 fs 包一起使用,在 react-native 中不受支持。显然,这个解决方案给我一个未知包“fs”的错误。但是,我尝试实现缓冲的想法。
所以,我使用了这个片段:
fetch(URL)
.then((response) => response.arrayBuffer())
.then((responseBuffer) => {
//What to do here?
})
responseBuffer 返回一个字节大小为几千字节的对象。任何帮助将不胜感激。
最佳答案
你最好的选择是使用为 React Native 编写的这些 zip 模块之一 -
https://github.com/plrthink/react-native-zip-archive
https://github.com/remobile/react-native-zip
https://github.com/wkh237/react-native-fetch-blob
关于react-native - 如何获取一个 zip 文件并解压到 ram 中 react native ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40611024/