I need to download 1000s of photos in react native for offline use. I use RNFetchBlob for android and RNFS for iOS to download all photos.
for android
RNFetchBlob.config({
path: `${Path.path}${fileName}.${type}`,
fileCache: true
}).fetch('GET', result, {})
.progress((received, total) => {
}).then(async res => {
deletePhoto(id)
console.log('downloaded', res)
}).catch((error) => {
downloadFile(fileName, result, type, id)
console.log('error in file download', id)
})
for iOS
RNFS.downloadFile({
fromUrl: result,
toFile:`${Path.path}${fileName}.${type}`,
background: true,
connectionTimeout: 1000 * 10,
readTimeout: 1000 * 10,
discretionary: true,
progressDivider: 1,
progress: (res) => {
// do progress
}
}).promise.then((result) => {
console.log('downloaded', result)
})
.catch(error => {
console.log('error in file download', error)
})
Problem
Time taken for downloading 800 files is for android - 2-3 minute depends on network-bandwidth and for iOS 20 minutes I don't know what i am doing wrong.
Any help will be useful to me thanks in advance