Downloading large files with AFNetworking

前端 未结 2 531
误落风尘
误落风尘 2021-02-04 20:50

I\'m trying to implement downloading of a large file and show to user current progress, but block in:

-[AFURLConnectionOperation setDownloadProgressBlock:] 
         


        
2条回答
  •  孤城傲影
    2021-02-04 21:43

    phix23 answered to my initial question, so there is really no problem with progress block. I'm answering to my edit.

    When success block in

    -[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]
    

    is called, I can compare the number of bytes downloaded with the number of bytes expected to download (it is not very hard to implement in code). If the number of downloaded bytes is smaller - I can continue file download from place where it was interrupted. To do this, I'm using Range http header in NSURLRequest, here is more information:
    Continue an interrupted download on iPhone
    How to implement resumable file downloads on iPhone SDK

    So, the problem is not really with AFNetworking (NSURLConnection has same behavior), but, I think, developers of the framework could take into account this situation.

提交回复
热议问题