itinance / itinance/react-native-fs
RNFS.readDir sees the file but RNFS.copyFile says the file "doesn't exist".
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
- "react": 17.0.2
- "react-native": 0.67.2
- "react-native-fs": ^2.19.0
- "react-native-image-crop-picker": ^0.37.3
- iPhone 13 sim running iOS 15.4
I am using `React Native Image Crop Picker` to select an image from the photo library and attempting to use `RNFS.copyFile` command to copy this image to a specified directory.
`RNFS.readDir` sees the file is there and I try to use the result.path from it to copy the file over but it says file doesn't exist.
Here is the code I'm using:
if (image) {
let imagePath = String(image).split('/');
let imageName = imagePath.pop();
let pathString = imagePath.join('/');
RNFS.readDir(pathString)
.then((result) => {
for (let i = 0; i < result.length; i++) {
if (result[i].name === imageName) {
console.log("Found selected image: " + result[i].path)
RNFS.copyFile(result[i].path, vehicleImagesPath + vehicleId + ".jpg")
.then(() => {
console.log("==> Vehicle image saved");
})
.catch((error) => {
console.log("==> Vehicle image NOT saved: " + error.message);
});
}
}
})
.catch((error) => {
console.log("No Dir Found --- " + image)
});
}
And here is the output I'm getting:

Found selected image: /Users/XXXXXXX/Library/Developer/CoreSimulator/Devices/13217381-22BA-459C-84C2-81E7F075D228/data/Containers/Data/Application/4FE78B68-643F-4F75-ADA3-2AF34B0C6FEC/tmp/react-native-image-crop-picker/4304270C-A5E8-4329-B586-A4139CDE8634.jpg
==> Vehicle image NOT saved: The file “4304270C-A5E8-4329-B586-A4139CDE8634.jpg” doesn’t exist.
So it's clearly seeing the file but `RNFS.copyFile` is having an issue finding it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.