kennyevo
kennyevo

Reputation: 681

Alamofire download progress totalBytesExpectedToRead always -1

I'm using Alamofire and found that with the download task and progress I get the correct bytes that it read and the total bytes currently read, but the totalBytesExpectedToRead always -1. Even in the test files the assertion says that this value should be always -1, why?

The download completes with no problem, but I want to show a progress bar while downloading PDF's.

Is it possible that this part of the library is not done yet?

Thank you in advance!

Upvotes: 6

Views: 1748

Answers (1)

Satish Azad
Satish Azad

Reputation: 2312

totalBytesExpectedToRead provides you the Content-Length that is received from server side. When server does not providing "Content-Length" value in response header then it would be -1 always. First confirm to webservices and from Web Developers team that they should provide you "Content-Length".

Actually, totalBytesExpectedToRead is give you the value from property of NSURLResponse of "expectedContentLength"

Upvotes: 7

Related Questions