Download file on iOS
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
@hoangvuanhdevelopervn @AravindTReddy , ref to https://github.com/itinance/react-native-fs/issues/897#issuecomment-759577180 , thus I can let .gif file saved with my APP PixelShapeRN running on iOS be located on the device with my APP and other APP, for example iOS "File Explorer" app now can find the .gif file and show for user.