RNFetchBlob.fs.exists crashes if the file not exist in the gallery (content://) on android
See original GitHub issueHi
I’ve an issue about the RNFetchBlob.fs.exists()
method.
Context :
- I’ve an app that record some videos
- this app stores recorded video using the CameraRoll component.
- Videos are stored in the gallery (content://media/external/video/media/296)
I’ve tested two things :
- The video exist in the gallery
- The video does not exist (remove manually by the user)
The code :
async componentDidMount() {
const {scene} = this.props;
// scene.film is the uri like content://media/external/video/media/296 (android only at the moment)
if (scene.film) {
RNFetchBlob.fs.exists(scene.film)
.then((exist) => {
console.log(`file ${exist ? '' : 'not'} exists`)
})
.catch((err) => { console.log(err) });
this.setState({jsx: this.renderFilm(scene)});
} else {
this.setState({jsx: this.renderImage()});
}
}
Version:
"react-native": "0.56.0",
"rn-fetch-blob": "^0.10.12"
The issue
If the file exist, everything works and console log print :
If the file has been removed the app crashes and shutdown. This behaviour have been tested on android 7.0, API 24 the device is : SM-T580
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
Read files function is crashing in RNFetchBlob in react native ...
I got it working by changing the download directory path. It was not working due to permissions issue.
Read more >How to use the rn-fetch-blob.fs function in rn-fetch-blob | Snyk
rn-fetch-blob. A module provides upload, download, and files access API. Supports file stream read/write for process large files.
Read more >rn-fetch-blob - npm
A module provides upload, download, and files access API. Supports file stream read/write for process large files.. Latest version: 0.12.0, ...
Read more >Use Filesystem - let's read and write the file by react-native-fs ...
(not available on Android); ExternalDirectoryPath: absolute path of External files, shared directory. (not available on iOS); ExternalStorageDirectoryPath: ...
Read more >How to access file systems with React Native - LogRocket Blog
Learn the fundamentals of react-native-fs, a library that allows ... is a minor flaw: what if the client wants to edit an existing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zibs Thanks I still have this issue now and I just use an ugly workaround like this :
Well like you see here even RNFS can’t make a proper exist method (it’s not handle the content:// return always false)
Using
stat()
fails to return the correct value forcontent:
files on android. @tmaly1980’s fix seems like it would fix this issue.