Android download manager is failing to download, even though download succeeds without download manager.
try {
const res = await RNFetchBlob.config({
addAndroidDownloads: {
useDownloadManager: true,
mime: 'image/png',
description: 'hiiii'
}
})
.fetch('GET', 'https://myseti.net/api/files/25844492-f7b7-4dcb-a9f7-4d65678ce6c7?version=original');
console.log('res:', res);
} catch(ex) {
console.warn('ex when downloading, ex:', ex);
}
The above gives error:
"Error: Download manager failed to download from https://myseti.net/api/files/25844492-f7b7-4dcb-a9f7-4d65678ce6c7?version=original. Statu Code = 16"
However this code works fine:
const res = await RNFetchBlob.config({
fileCache: true,
appendExt: 'png'
})
.fetch('GET', 'https://myseti.net/api/files/25844492-f7b7-4dcb-a9f7-4d65678ce6c7?version=original');
But this does not use download manager. :(
Is it possible the cookies from the regular fetch call is not being used by the download manager? Is there a way to make it use the cookies? I tried this but it didnt help:
const res = await RNFetchBlob.config(....)
.fetch('GET', originalUrl, {
'Set-Cookie': '................' // i added cookie here
});
Here are the notifications that show after the above fails:

That one on the bottom with custom notification title is because i used the .config options to set a custom notif title.
Yes this was the problem. I had to do a dummy request, then set Cookie header in order for it to work:
// dummy request to figure out cookie
const resCookie = await fetchApi('session');
if (resCookie.status !== 200) return alert('Failed to download, you must not be logged in anymore.');
const cookie = resCookie.headers.map['set-cookie'][0];
// download it
const res = await RNFetchBlob.config({
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true,
mime: mimeType,
description
}
})
.fetch('GET', originalUrl, { 'Cookie':cookie });
If i don't use the download manager, then the normal cookies used by normal fetch are also used by RNFetchBlob.fetch.
any progress?
Most helpful comment
any progress?