I need to download sample file to my iOS/Android device which is placed in application's assets folder with react native. I have implemented below code.
const assetPath = 'assets/icons/bootsplash.png';
const destinationPath = `${RNFS.DocumentDirectoryPath}/bootsplash.png`;
RNFS.copyFile(assetPath, destinationPath)
.then(assetData => {
console.log('assetDataassetData:', assetData);
})
.then(() => {
console.log('Asset copied successfully to:', destinationPath);
})
.catch(error => {
console.error('Error copying asset:', error);
});
But showing error like
Error copying asset: [Error: The file “bootsplash.png” couldn’t be opened because there is no such file.]
Try change destinationPath to:
Also try to use copyFileAssets method on Android like this:
If everything above not working, сheck the correctness of assetPath.