After writing data to a file using react-native-fs where does the file go?
I am able to write the file and view it when i am testing in my local machine using ExternalStorageDirectoryPath
in android But when i push my app to play store I am unable to perform the write operation.
Same thing is happening while using DocumentDirectoryPath
in IOS
I can find the file in emulator and external device when i run react-native-run-android
but not when i published the app.
Reference: Saving a files in React-Native using reart-native-fs In this post only files are shown from emulators and i am looking for a solution to find the file in real world devices after installing my app. Thanks
Below is my code
fetch('https://xxxxxxxxxxxx.execute-api.us-east-1.amazonaws.com/prod/export', {
method: 'post',
headers:{
'Accept': 'application/json',
'Content-type': 'application/json'
},
body:JSON.stringify({
deviceid: item,
fromtime: myEpoch1.toString(),
totime: myEpoch2.toString()
})
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
this.setState({exportButton:false});
if(responseJson){
var path = RNFS.ExternalStorageDirectoryPath + '/'+ myEpoch1 +'-to-'+ myEpoch2 +'.json';
RNFS.writeFile(path, JSON.stringify(responseJson), 'utf8')
.then((success) => {
console.log('FILE WRITTEN!');
Alert.alert(
'Sucesss: File saved',
'File downloaded and saved successfully to ' + path + ' device' ,
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: () => console.log('OK Pressed')},
],
{ cancelable: false }
)
})
.catch((err) => {
console.log(err.message);
});
}
})```