Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Alamofire,发现通过下载任务和进度,我得到了它读取的正确字节数和当前读取的总字节数,但 totalBytesExpectedToRead 始终为-1。即使在测试文件中,断言也说这个值应该总是-1,为什么?
下载完成没有问题,但我想在下载 PDF 时显示一个进度条。
库的这部分可能还没有完成吗?
先感谢您!
totalBytesExpectedToRead 为您提供从服务器端接收的 Content-Length。当服务器未在响应标头中提供“Content-Length”值时,它将始终为 -1。首先向 Web 服务和 Web 开发团队确认他们应该为您提供“内容长度”。
实际上,totalBytesExpectedToRead 是为您提供“expectedContentLength”的 NSURLResponse 属性的值