Open DiuChen opened 6 years ago
在日志里你应该能看到这一行:
W/FileDownloader.FileDownloadUtils: don't get instance length fromContent-Range header
即在 trail connection 中没有获取到文件大小,所以 FileDownloader 把它当成 chunk 资源下载,此时 totalBytes 就一直是 -1 。
我用1.7.5也碰到了这种情况,totalBytes 一直是-1。然后尝试其他版本发现1.6.9版本是可以的,但是这个版本又无法支持断点续传功能。 @rantianhua
感觉是断点续传功能导致的bug,断点续传不应该默认支持,因为断点续传是需要后台支持的,应该提供打开或关闭断点续传的开关,没有断点续传之前的功能是正常的,回调能拿到文件大小。
经过多次不同版本尝试,发现1.7.1都是好的,1.7.2就不行了,应该是1.7.1到1.7.2版本升级修改的内容导致此bug,哪里可以看到之前版本修改的内容?
你可以再 https://github.com/lingochamp/FileDownloader/releases 这里看到每个版本的 changelog 。
楼主解决了吗 分享一下 我遇到的问题跟你一样
这里跟断点续传无关。之所以你遇到这个问题,是服务端没有严格按照协议返回 Content-Range 字段,所以没有获取到文件大小。1.7.1 到 1.7.2 的修正正是从 Content-Length 读取文件大小改为了从 Content-Range 读取,同时请求是 range 变为 0-0 。
还可以尝试配置 filedownloader.properties :
download.trial-connection-head-method=true
试试用 HEAD 方法获取文件大小是否支持。
自己测试想下载该项目zip包路径为:https://github.com/lingochamp/FileDownloader/archive/master.zip 结果一直无法获取到文件大小,开始还以为自己理解不对,于是运行了demo把下载路径替换为该路径结果无法显示进度,自己打印日志文件大小也为-1,想不通