I use react-native-fs to download file in iOS. I check on simulator it's download success with path:
_/Users/admin/Library/Developer/CoreSimulator/Devices/443C8F7F-AB92-4217-A999-A7BDBA52A6B6/data/Containers/Data/Application/99958A5C-E350-4855-B8CE-ED6FA999C619/Documents._
On real device, it's path (iPhone 8 Plus White 64Gb):
_/var/mobile/Containers/Data/Application/63F84623-E684-456F-A55A-01E22708C012/Documents/pexels-photo-1109561.jpeg_
I try set: _const destPath = RNFS.DocumentDirectoryPath + '/images/' + name;_
but it't not work. I want to this image display on photo, this mean after download success i can see it on my photo immediately, how can do that and what about the others file like: mp3, mp4, text, after download, how to find it's and show for user when they want to read?
This is my code:
downloadFile1 = (url, name) => {
const destPath = RNFS.DocumentDirectoryPath + '/images/' + name;
let option = {
fromUrl: url,
toFile: destPath
};
RNFS.downloadFile(option).promise.then(res => {
console.log('res -----------------------------> ', res);
});
};
Had similar issue and I think I found the problem:
It's because you want to store the file in a dir images that doesn't exist yet. Either drop this from the destPath or make sure this dir exists before starting the download.
Hey @hoangvuanhdevelopervn , Have you figured out a way to find the file and show for user when they want to read?
Is there a way to navigate to this path :
/var/mobile/Containers/Data/Application/63F84623-E684-456F-A55A-01E22708C012/Documents/pexels-photo-1109561.jpeg
Thanks
Most helpful comment
Had similar issue and I think I found the problem:
It's because you want to store the file in a dir
imagesthat doesn't exist yet. Either drop this from thedestPathor make sure this dir exists before starting the download.