This example worked in v1.5.1, but seems to have broken since v2.0.0:
RNFS.downloadFile(url, path).then(res => {
this.setState({ downloaded: true });
});
Could you add a working example of downloadFile usage in the README?
RNFS.downloadFile(url, path).promise.then(res => {
this.setState({ downloaded: true });
});
The document here is clear
As per the document,
RNFS.downloadFile(url, path).promise.then(res => {
this.setState({ downloaded: true });
});
seems to be invalid, the following one works as of today.
RNFS.downloadFile({fromUrl:url, toFile: path}).promise.then(res => {
this.setState({ downloaded: true });
});
Thank you @kiliwalk
Thank you so much.Now it's working !!
Hi
I'm having this error
Error: ENOENT: no such file or directory, open '/data/user/0/com.kwanzaonline.toqueplay/files/download'
at createErrorFromErrorData (D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:146)
at D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:95
at MessageQueue.__invokeCallback (D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:397)
at D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:127
at MessageQueue.__guard (D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:297)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (D:\dev\mobile\toqueplay\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:126)
at debuggerWorker.js:72
Any help?
it is working and downloading file but i dont see that file in the photo app
When you trigger this function, what's the default behavior per OS?
I'm expecting that when the user taps the download button, it will open a file browser to let the user choose the download location. So in the future the user can open the file from his phone from outside the app.
What will it actually do on iOS and on Android?
ES6 style
const downloadFile = async () =>{
try{
const data = await RNFS.downloadFile(url, path).promise;
if(data){
this.setState({ downloaded: true });
}
}catch(error){
console.log('error', error)
}
}
it is working and downloading file but i dont see that file in the photo app
I have the same problem, how did you resolved it?
Most helpful comment
As per the document,
seems to be invalid, the following one works as of today.
Thank you @kiliwalk