I am using react-native-image-picker to get image from the system. As soon as the user selects and image, i am dispatching an redux action and it looks like this.
imgSrc variable contains image URI. I used split and pop to get the image name. But still the image has not been copied from imgSrc to my new generated path.
export const addPlace = (title , address , imgSrc) =>{
return async dispatch => {
const fileName = imgSrc.split('/').pop()
const newPath = RNFetchBlob.fs.dirs.DocumentDir + '/' + fileName
try{
await RNFetchBlob.fs.cp( imgSrc , newPath)
} catch ( err){
console.log('error')
throw err
}
dispatch({
type : ADD_PLACE ,
placeData : {
title : title,
address : address,
src : newPath
}
})
}
}