Downloading large files with AFNetworking
        Posted  
        
            by 
                goodfella
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by goodfella
        
        
        
        Published on 2012-11-03T08:14:14Z
        Indexed on 
            2012/11/04
            23:00 UTC
        
        
        Read the original article
        Hit count: 287
        
I'm trying to implement downloading of a large file and show to user current progress, but block in:
-[AFURLConnectionOperation setDownloadProgressBlock:] 
returns incorrect bytesRead and totalBytesRead values (they are smaller than they should be).
For example: If I have a 90MB file and when it downloads completely, latest block invocation in setDownloadProgressBlock: gives me totalBytesRead value about 30MB. On other side, if file is 2MB large, latest block invocation gives correct totalBytesRead 2MB value.
AFNetworking is updated to the latest version from github.
If AFNetworking can't do it correctly, what solution can I use?
Edit: I've determined that even if file is not downloaded completely (and this happens every time with relatively big file) AFNetworking calls success block in:
-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure]
I asked a similar question here about this situation, but didn't get any answers.
I can check in code downloaded and real file sizes, but AFNetworking has no API for continuation of partial download.
© Stack Overflow or respective owner