Issue:
path.startsWith is not a function
at normalizeFilePath (FS.common.js:28)
at Object.copyFile (FS.common.js:200)
at BackgroundSettingsComponent.js:243
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:298
at _callTimer (JSTimers.js:152)
at _callImmediatesPass (JSTimers.js:200)
at Object.callImmediates (JSTimers.js:473)
at MessageQueue.__callImmediates (MessageQueue.js:337)
Code:
````
onUploadCustomPhoto() {
ImagePicker.openPicker({ multiple: false })
.then(image => {
console.log('image.path', image.path)
ImagePicker.openCropper({
path: image.path,
width: width,
height: height,
})
.then(editedImage => {
let editedImagePath = editedImage.path;
let date = new Date();
let timestamp = Math.floor(date.getTime() + date.getSeconds())
const pathToImage = RNFS.DocumentDirectoryPath}/mood-pixel-background-time${timestamp}.jpg;
console.log('editedImagePath', editedImagePath, typeof editedImagePath)
try {
RNFS.copyFile({
filePath: editedImagePath, //Platform.OS === 'ios' ? `file://${editedImagePath}` : `${editedImagePath}`,
destPath: pathToImage,
}).then(response => {
console.log('response', response)
})
} catch (error) {
console.log('error in trycatch', error)
}
})
})
}
````
Console:

Any ideas why this might be happening?
I am using this package to download images from a server and it works perfectly. However, .copyFile is not working.
"react": "16.8.3",
"react-native": "0.59.8",
"react-native-fs": "^2.13.3",
"react-native-image-crop-picker": "^0.24.1",
My bad.
RNFS.copyFile({
filePath: editedImagePath, //Platform.OS === 'ios' ? `file://${editedImagePath}` : `${editedImagePath}`,
destPath: pathToImage,
})
It should be to parameters not an object.
i did not understand your hack
The error path.startsWith is not a function is raised when you pass a non String type, to copyFile(), for example an Object.
In my case I was passing in a Promise - I'm still kicking myself. String.startsWith docs
Most helpful comment
The error
path.startsWith is not a functionis raised when you pass a nonStringtype, tocopyFile(), for example an Object.In my case I was passing in a Promise - I'm still kicking myself. String.startsWith docs