Open Noitidart opened 6 years ago
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?
Android download manager is failing to download, even though download succeeds without download manager.
The above gives error:
https://github.com/wkh237/react-native-fetch-blob/blob/5f3c018b0a2b11246d1cce5b41f20634a2cf2d85/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java#L651
However this code works fine:
But this does not use download manager. :(