Reputation: 1613
I have a problem when downloading a zip file in chunks using NSURLConnection.
-(void)connection: didReceiveData:(NSData *)data method.
There are 2 ways I have tried, the first was to append all data to an NSMutableData
object, and call writeToFile:atomically:
at the end. This worked for a small video (14MB), but with the larger videos I am downloading, it was too much to keep in memory.
The second way is to call writeToFile:atomically:
as the data is coming in, which seemed to work for the download, but not for the unzip. This is the preferred method, but i'm not sure if the file is being reconstructed correctly as it will not unzip.
Any help would be much appreciated,
Upvotes: 0
Views: 629
Reputation: 6385
The second approach seems correct to me. You definitely need to write data to disk if it's too big to keep in memory. And by no means this should affect your ability to unzip it. So my guess is you are doing something wrong with unzipping. Do you use SSZipArchive? (it actually takes an URL to your zip file so it needs to be saved on disk anyway).
Upvotes: 1