5

There very well may be an answer to this already on SO, but I'm not familiar enough with compression formats to know if they're applicable to my case. So here's what I need:

1) Download a *.tgz file that is greater than 200MB. 2) Unpack it to a specified subdirectory of the Documents folder.

I know how to make the connection and begin downloading. But how do I download to an actual file (rather than storing it in memory), and once this download is complete how do I unpack it to my desired location?

maxedison
  • 17,243
  • 14
  • 67
  • 114

2 Answers2

0

To save the downloaded data to a file, see this SO-question and answer(s): The easiest way to write NSData to a file

To uncompress .tgz-files, see this question and answer(s): "Untar" file on iPhone

To download large files, see this question and answer(s): How to download large files using objective c on iphone

(Google is an awesome tool, really.)

Just as a sidenote, an app shouldn't download 200MB of data. It is time- and bandwith consuming and may cause Apple to reject your app.

Community
  • 1
  • 1
Emil
  • 7,220
  • 17
  • 76
  • 135
  • Thanks. I did spend time trying to find answers, but part of my problem is that I didn't have the necessary vocab (ie I didn't know "untar" was the term for decompressing tgz). – maxedison Jan 23 '12 at 14:58
  • Regarding your sidenote, can you recommend a place to ask questions about app submission issues like this? My company makes desktop software. The app is just a free add-on for our customers. It includes a lot of audio (hence the large file size), without which the app would be useless. I see here that there are a couple options for specifying which files should not be backed up to iCloud. Any idea if this removes the risk of rejection based on the need to download so much data? – maxedison Jan 23 '12 at 15:01
  • It depends on the description of the download to the user, I think. I am however not the right guy to ask, so I suggest you post another question in regards to this :) Also, if this question helped you, I would appreciate it if you voted it up or accepted it by clicking the ✔ next to the answer :) – Emil Jan 23 '12 at 15:09
  • 1
    I've upvoted. I'll get a chance to try out the things you linked to this evening, at which point I imagine I'll accept your response as the answer. – maxedison Jan 23 '12 at 15:48
0

Forget NSURLConnection; use ASIHTTPConnection (google it) which has an easy save to file option. (And resumes failed downloads too)

I don't know the answer to tar/gzip. My application uses zips instead and http://code.google.com/p/ziparchive/wiki/PageName does the trick.

baswell
  • 826
  • 1
  • 7
  • 5