version: "react-native-fs": "2.13.3"
platform: iOS
code:
let documentPath = RNFS.DocumentDirectoryPath;
let zipPath = documentPath+'/app.zip'
let options = {
fromUrl: downLoadUrl,
toFile: zipPath,
background: true,
progressDivider: 5,
discretionary: true,
cacheable: true,
begin: (res) => {
console.log('begin', res);
},
progress: (res) => {
console.log('progress', res)
}
}
let ret = RNFS.downloadFile(options);
ret.promise.then(res=>{
console.log('====================================');
console.log('complete',res);
console.log('====================================');
}).catch(err=>{
console.log(err);
})
问题找到了, iOS原生代码,Downloader.m文件中,有判断,如果[_statusCode isEqualToNumber:[NSNumber numberWithInt:200]]才会进入进度更新的回调. 其它一概不接受.我们服务端返回的是_statusCode 等于 201.
I think it is necessary to fix this problem.
@xclidongbo it looks like when I provide begin callback together with progress (even when begin is noop function), then progress is working correctly again.
Can you check?
@sebinq you saved my day, thanks!
mine too! thanks @sebinq but funny, I remember this working without begin
@LuisRodriguezLD yep, it was working before just fine. I don't know what what has changed :D But it is good that there is this hack which make it works again.
@sebqq Thanks !, Saved my evening :-p
Glad to help 🍻
Most helpful comment
@xclidongbo it looks like when I provide
begincallback together withprogress(even when begin is noop function), then progress is working correctly again.Can you check?