Download large files

I am currently developing an application that should show offline videos that need to be downloaded first.

The problem was that these videos may be larger than the memory that I can allocate for my application. Therefore, the loaded parts should be immediately saved, not saved in the NSData object. I hear conflicting stories about whether RESTKit should work, and ASIHTTPRequest seems to be out of date.

I will follow the suggestion from this thread as it seems to be the best option.

NSURLConnection download large file (> 40MB)

+4
source share
3 answers

Consider using NSURLConnection to upload a video file and write data directly to a file ( NSFileHandle ).

One of the advantages of using this method is that the delegate method NSURLConnection didReceiveData constantly called when data is received, so you can update the progress bar.

+3
source

Check out AFNetworking for network management. I'm not sure if they have video downloads, but the structure works great for images and other types of downloads that I had before.

0
source

Without explaining all the hashes with handling HTTP responses in chunks and streams, I would recommend using AFDownloadRequestOperation . It supports resuming downloads and has callbacks to show downloads. I love it and use it in most of my projects.

PS It uses AFNetworking , which is an excellent basis for creating all kinds of HTTP requests.

0
source

Source: https://habr.com/ru/post/1495975/


All Articles