I am trying to open pdf files which gets downloaded through the android download manager in react native . I have used rn-fetch-blob for this and I think am unable to set the path in the download manager... here is code for it ... tried opening files from the notifications but was not able to do so , every time i clicked on the "file downloaded successfully notification" got an toast error saying "Can't open file".
const downloadFile = fileUrl => {
let date = new Date();
let FILE_URL = fileUrl;
let file_ext = getFileExtention(FILE_URL);
file_ext = '.' + file_ext[0];
const {config, fs} = RNFetchBlob;
let RootDir = fs.dirs.DownloadDir;
let options = {
fileCache: true,
addAndroidDownloads: {
path:
RootDir +
'/file_' +
Math.floor(date.getTime() + date.getSeconds() / 2) +
file_ext,
description: 'downloading file...',
notification: true,
useDownloadManager: true,
},
};
config(options)
.fetch('GET', FILE_URL)
.then(res => {
console.log('res -> ', JSON.stringify(res));
});
};