Skip to content
This repository has been archived by the owner on Nov 24, 2017. It is now read-only.

Possible Unhandled Promise Rejection (id: 0): undefined is not an object (evaluating 'RNFS.DocumentDirectoryPath') #10

Closed
32xnabin opened this issue Jul 7, 2017 · 1 comment

Comments

@32xnabin
Copy link

32xnabin commented Jul 7, 2017

///////inside package.json

"react-native": "git+https://github.com/exponentjs/react-native#sdk-12.0.0",
"react-native-cache-image": "^1.0.0",
"react-native-file-download": "0.0.10",
"react-native-fs": "^2.3.3",

///////inside component

const FileDownload = require('react-native-file-download');
const RNFS = require('react-native-fs');
const URL = downloadpath;
const DEST = RNFS.DocumentDirectoryPath
const fileName = 'zip.zip'
const headers = {
'Accept-Language': 'en-US'
}

FileDownload.addListener(URL, (info) => {
console.log(complete ${(info.totalBytesWritten / info.totalBytesExpectedToWrite * 100)}%);
});

FileDownload.download(URL, "DEST", fileName, headers)
.then((response) => {
console.log(downloaded! file saved to: ${response})
})
.catch((error) => {
console.log(error)
})

@plrthink
Copy link
Owner

I might address this issue on react-native-fs according to the error log. Also, please note that this package is marked as out of maintenance, I recommend to use downloadFile from react-native-fs to achieve this functionality.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants