Open wamry opened 5 years ago
Can confirm.
I had to serialize my downloads to fix this problem.
Confirm.
Faced absolutly the same issue.
this is a big issue and should be resolved as fast as possible if you find a solution don't forget to post here @Macromeda
This seems to happen with other (all?) promise-based calls too. For example, parallel calls to RNFetchBlob.fs.exists
will all resolve to the same result, even if they were called with a different path to check.
Can confirm.
I had to serialize my downloads to fix this problem.
Thanks for the hint, but what do you mean by that? What exactly have you done to get rid of the problem?
I started one with await or then() waited till it finished, then started the next, awaited/thened it, etc.
I started one with await or then() waited till it finished, then started the next, awaited/thened it, etc.
Thanks for a quick answer and your solution. This won't work for us, as we download all images of the app this way, so it needs to be done fast. I think this bug is the reason, that sometimes some of the images look corrupted, half grey.
Since the authors of this library are not replying, i'm guessing it's dead. I recommend using "react-native-fs" library, i've used it myself and it's perfect for uploading and downloading.
I started with react-native-fs
but I couldn't find a generic way to download files of different (and possibly unknown) types. An equivalent to this library's RNFetchBlob.fetch
in other words. Do you know if that is doable?
@silvainSayduck hi! I am implementing it now, it looks good. Here is how you make it:
RNFS.downloadFile({
fromUrl: uri,
headers: source.headers,
toFile,
progress: (res: DownloadProgressCallbackResult) => {
// do progress
}
})
.promise.then((result: DownloadResult) => {
// do result
})
.catch(error => {
// do error
});
Hi, thanks for the pointer, I'll give it a try soon :)
Anyone knows what version causes this? It seemed to have popped up out of nowhere without updating versions.
EDIT: I tried using react-native-fs, but a) it performs much worse than this and b) downloading multiple small files seems to be broken there as well.
@schumannd unfortunately your solution is not working for me. any other suggestion?
I tried to create a chain promise but did not work also.
let productImageList = res.result.productImageList;
let dirs = RNFetchBlob.fs.dirs;
let promiseChain = Promise.resolve();
for(let i = 0, len = productImageList.length; i < len; i++){
let item = productImageList[i];
if (item.image_url) {
timeout(1000);
const next = async (link) =>{
let image_name = link.toString().split('/').pop().split('#')[0].split('?')[0];
let path = dirs.DocumentDir + '/Downloads/Images/' + image_name;
link = encodeURI(link);
try {
const res = await RNFetchBlob
.config({
path: path,
fileCache: true
})
.fetch('GET', link, {});
return res.path();
}
catch (err) {
Warning(err.message, "img download error");
}
}
promiseChain = promiseChain.then(next(item.image_url));
item.image_url = getFilePath(item.image_url);
images.push(item);
}
}
My issue was actually a call I made to this deprecated API.
Once I removed that call, everything worked again. Try to remove any unnecessary code.
I think I fixed this with #558. I noticed that uploading or downloading multiple things works, but you don't get any progress back for them on iOS. This is because the download/upload progress configs were being removed from a dictionary. Simple (but significant) fix.
Any news when this might be merged in?
What happens when I try to download several files on ios, that some of them will go right into "then"(success) callback, and not in the progress callback.
Issue was reported on another repo related to this one: https://github.com/wkh237/react-native-fetch-blob/issues/263
rn-fetch-blob: 0.10.15 react-native: 0.57.5