Javascript React本机获取blob下载文件

Javascript React本机获取blob下载文件,javascript,react-native,react-native-fetch-blob,Javascript,React Native,React Native Fetch Blob,我只想让我的应用程序使用react native fetch blob从服务器下载一个文件。问题是,文件存储在哪里?我只是将react native fetch blob的回调记录到console.log中,并得到了这个对象 这是我的密码 alert("downloading"); RNFetchBlob .config({ useDownloadManager : true, fileCache : true }) .fetc

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

这是我的密码

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());
    })

有什么解决方案吗?

我正在使用它,而且效果非常好。 你只需要得到这样的路径

var filePath = res.path();

这是存储文件的地方。

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

顺便说一句,不再维护,请改用

函数下载文件(url,文件名){
const{config,fs}=RNFetchBlob;
const downloads=fs.dirs.DownloadDir;
返回配置({
//添加此选项,使响应数据存储为文件,
//这更有效。
fileCache:true,
AddAndroid下载:{
useDownloadManager:是的,
通知:虚假,
路径:下载+'/'+文件名+'.pdf',
}
})
.fetch('GET',url);

}
我以前做过,但它返回空字符串
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())
  })