Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 442
kennyevo Avatar asked Dec 10 '14 09:12

kennyevo


1 Answers

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"

like image 199
Satish Azad Avatar answered Oct 05 '22 12:10

Satish Azad