gpt4 book ai didi

javascript - React-native-fetch-blob 下载文件

转载 作者:太空宇宙 更新时间:2023-11-04 15:32:56 24 4
gpt4 key购买 nike

我只想让我的应用程序使用react-native-fetch-blob从服务器下载文件。问题是,文件存储在哪里?我只是console.log来自react-native-fetch-blob的回调并得到了这个对象

React-native-fetch-blob object callback

这是我的代码

alert("downloading");
RNFetchBlob
.config({
useDownloadManager : true,
fileCache : true
})
.fetch('GET', 'http://fontawesome.io/assets/font-awesome-4.7.0.zip', {})
.then((res) => {

console.log(res);
alert("Download");
alert('The file saved to ', res.path());
})

有什么解决办法吗?

最佳答案

要使用rn-fetch-blob直接下载文件,需要将fileCache设置为true。

顺便说一句,react-native-fetch-blob不再维护,使用rn-fetch-blob相反

document of download file directly

RNFetchBlob
.config({
// add this option that makes response data to be stored as a file,
// this is much more performant.
fileCache : true,
})
.fetch('GET', 'http://www.example.com/file/example.zip', {
//some headers ..
})
.then((res) => {
// the temp file path
console.log('The file saved to ', res.path())
})

关于javascript - React-native-fetch-blob 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44652935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com