react-native-blob-util
react-native-blob-util copied to clipboard
Android 14: Error: Download manager download failed, the file does not downloaded to destination.
Package.json
"react": "18.2.0",
"react-native": "0.73.2",
"react-native-blob-util": "0.19.4",
Build params:
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
When I try to download the file I get an error (Error: Download manager download failed, the file does not downloaded to destination.), but the file itself is downloading
const BASE_DIR = Platform.OS === 'ios' ? RNFetchBlob.fs.dirs.CacheDir : RNFetchBlob.fs.dirs.DownloadDir;
const filePath = `${BASE_DIR}/${fileName}`;
const isExist = await RNFetchBlob.fs.exists(BASE_DIR);
if (isExist) {
return RNFetchBlob.config({
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
description: `${t('Downloading file')}...`,
path: filePath,
title: fileName,
mediaScannable: true,
},
overwrite: true,
fileCache: true,
indicator: true,
path: filePath,
}).fetch(method, path, headers, body);
}
Logcat details:
same issue any solution?
facing same issue while downloading.....
Same issue here. It seems to fail only in Android 14.
@marcelormourao no Its also fail on Android 13 devices as well.
initially I'm facing Cannot read property 'rnfbEncode' of undefined to fix this I wrap the path with ReactNativeBlobUtil.wrap(path) but when downloading start its save on download folder but also its showing me Download manager download failed.
The same problem happened! But after downgrading to [email protected] based on this this Everything is working again! But still need to look into that issue.
@dangleh Did you figured out any solution for this ?
using 0.19.4 isn't working for me. I am getting same issue. File is downloaded, but getting the download manager error. I can see the file in the my app's download folder, but from the download manager pop-up it says "can't open file". I tried writing to root Download folder, but seeing same behavior. I have RN 0.73.3 and API Level = 33, means I should care about the permissions.
version 0.19.8 also shave same issue
version
0.19.8also shave same issue
Downgrading to version 0.19.4 worked for me, make sure you are now using ^for the package
Having the issue with 0.19.4 too. The image is correctly downloaded but still have this error...
@AntonyARHS can you share your package.json file?
0.19.9 have same issue
Can you try using react-native-blobl-util package instead of rn-fetch-blob as rn-fetch-blob is not maintained anymore.
export const onFileDownload = async (uri, callback) => {
const fileName = uri?.split("/")?.pop();
const { dirs } = RNBlobUtil.fs;
const dirToSave = isIOS ? dirs.DocumentDir : "/storage/emulated/0/Download";
const path = `${dirToSave}/${fileName}`;
RNBlobUtil.config({
fileCache: true,
path: path,
appendExt: "pdf",
overwrite: true,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
mediaScannable: true,
title: fileName,
description: "Downloading file",
path: path,
},
})
.fetch("GET", uri)
.then((res) => {
if (isIOS) {
callback && callback();
RNBlobUtil.fs.writeFile(path, res.data, "base64");
RNBlobUtil.ios.previewDocument(path);
}
if (isAndroid) {
callback && callback();
showToast("File downloaded");
}
})
.catch((e) => {
showToast(e?.message);
console.log("file save ERROR", e.message);
});
};