[Error: Download manager download failed, the file does not downloaded to destination.]
See original GitHub issueI am trying to donwload image Here image do get to destination folder but the problem is it gives error saying
[Error: Download manager download failed, the file does not downloaded to destination.]
- “react-native”: “0.63.0”, *“rn-fetch-blob”: “^0.12.0”
Code Snippets
const checkPermission = async (image: string) => {
if (Platform.OS === 'android') {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
{
title: 'Storage Permission Required',
message: 'This app needs access to your storage to download Photos',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('Storage Permission Granted.');
handleDownload(image);
} else {
Alert.alert('Storage Permission Not Granted');
}
} catch (err) {
console.warn(err);
}
}
};
const getExtention = (filename: string) => {
//To get the file extension
return /[.]/.exec(filename) ? /[^.]+$/.exec(filename) : undefined;
};
const handleDownload = async (image: string) => {
let date = new Date();
let image_url = image;
let ext = getExtention(image_url);
const {config, fs} = RNFetchBlob;
let pictureDir = fs.dirs.PictureDir;
let options = {
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
path:
pictureDir +
'/wallace_' +
Math.floor(date.getTime() + date.getSeconds() / 2) +
'.' +
ext,
description: 'Image',
},
};
config(options)
.fetch('GET', image_url)
.then((res) => res.json())
.then((res) => {
console.log(res.path());
Alert.alert('Image Downloaded Successfully.');
})
.catch((err) => {
console.log(err);
// Alert.alert('Download Failed', err.message);
});
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Download manager download failed the file does not ...
I am using rn-fetch-blob package to download file. ... Download manager donwload failed , the file does not downloaded to destination.
Read more >Windows 11 problem with downloading files
I tried install something with Steam, Internet Download Manager and Chrome but all the downloads kept failing.
Read more >FTP File error "Exception in Task - Forum - VisualCron
The error is "Exception in Task: Failed to download file" but when looking at the destination side of the download task I see...
Read more >Akamai Download Manager FAQ - Adobe Support
Keep the web browser and the Akamai Download Manager 3 window open until the download completes. If you close either window prematurely, the ......
Read more >PowerShell wget : Awesome Way to Download a File
Why not use PowerShell to download files much like an alternative ... file's location and the destination path to save the downloaded files....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have also faced the similar issue i.e. write file on documentDir simply crashed for me. My project configuration is:
I found a workaround in Android documentation, which is, add
android:requestLegacyExternalStorage="true"
inAndroidManifest.xml
file:<application android:requestLegacyExternalStorage="true" ...
Reference: https://developer.android.com/reference/android/R.attr#requestLegacyExternalStorage
Hope that this will be useful for some of you who are struggling with crash/failure of
rn-fetch-blob
withAndroid sdk 29
I solved it. In my case, there was a problem about filename.
As you can see, there are some special characters that are not allowed to use in filenames in android. The characters below are those.
\ < > * " : ? \ |
this is my configOptions at first
but there were problems when the filename contains
\ < > * " : ? \ |
. I think android download manager automatically change the characters above to_
and store in phoneso I changed the filepath like this(replace
\ < > * " : ? \ |
to_
in filePath