Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30336

Download Audio file in react native?

$
0
0

I'm trying to download audio file "mp3" using rn-fetch-blob.

So I have more than one cases :)

When I trying to add a path to RNFetchBlob config like this

const pathFile = RNFetchBlob.fs.dirs.MainBundleDir // Or .DocumentDir // Others is crashed my App 'Android';

The callback "then" get success so i log console.log('The file is saved to ', res.path()) But when I try to explore this file in my real device I can't find them I don't know why!

So there's one faced same issue like this in Android?

startDownload = () => {
    const {url} = this.state;
    const pathFile = RNFetchBlob.fs.dirs.DocumentDir;
    let date = new Date();
    RNFetchBlob.config({
      fileCache: true,
      path:
        pathFile +
        '/me_' +
        Math.floor(date.getTime() + date.getSeconds() / 2),
    })
      .fetch('GET', url)
      .then(res => {
        console.log('The file is save to ', res.path()); // It's log here but i can't see the file :\
      })
      .catch(err => console.log('err', err));
  };

Viewing all articles
Browse latest Browse all 30336

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>