react-native-fs: for existed file 'content://' exists returns false
I have image file (obtained by using device camera) with following uri
content://media/external/images/media/331
using RNFS.exists.then returns false while file is exists.
how to fix this?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 6
- Comments: 20 (3 by maintainers)
Here’s a workaround until we get native support:
I ran into this issue recently when trying to upload a file that was shared to my app (via the
react-native-share-menumodule). The file that it was trying to upload started withcontent://and so whileRNFS.statas well asRNFS.uploadFilesthrew an exception when trying to handle that file,RNFS.copyFilecould work with it just fine. So here’s my workaround:Basically, I’m just copying the file over to my app’s own directory for handling. But with the web server I was uploading the images to, the file extension is required and in this case the file extension wasn’t in the file path, luckily the share module gives me the MIME type and my application only supports a limited number of types so I was able to make do.
@llaine Use
RNFS.statshould do the trick.