joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.8k stars 770 forks source link

[Error: Download manager download failed, the file does not downloaded to destination.] #785

Open AeronDev69 opened 2 years ago

AeronDev69 commented 2 years ago

Just got an error log message, but the download was successful. The big problem was i cant log the response

`const download = (url: any, name: string) => {
  RNFetchBlob.config({
    fileCache: true,
    appendExt: 'mp3',
    addAndroidDownloads: {
      useDownloadManager: true,
      notification: true,
      title: name,
      path: RNFetchBlob.fs.dirs.DownloadDir + '/' + name.replace(/ /g, '_'),
      description: 'Downloading file',
    },
  })
    .fetch('GET', url)
    .progress({count: 1}, (received, total) => {
      console.log('Progress', (received / total) * 100);
    })
    .then(res => {
      console.log('res', res);
      console.log('file save to' + res.path());
    })
    .catch(err => console.log(err));
};
`const requestPermission = async (link: string | undefined, fileName: any) => {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      {
        title: 'Music',
        message: 'App need to access files',
        buttonNeutral: 'Ask Me Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
      },
    );
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      console.log('startDownload');
      download(link, fileName);
    }
  } catch (err) {
    console.log('err:' + err);
  }
};
AparnaManjalavil commented 1 year ago

I'm also facing the same error. Pls help me