When downloading data from a server thats compressed using zlib, I was wondering what steps are needed to take to uncompress and save to core data
any help would be greatly appreciated
Use something like ASIHTTP to retrieve the file off the network. That can handle gzip which is likely what the data coming off the network is compressed with.
If you'd prefer to roll your own, take a look at this zlib category on NSData: Has worked well for me in the past and likely does what you'll need.
You'll also need to add -lz to the "other linker flags" build setting
Related
I would like to implement zip decompression without using external frameworks. I think that Compression framework from iOS SDK should be ok for this, but I'm not sure. I was looking for some examples on how to extract files using this but found nothing. I wan't to extract all files from zip to some directory (not Data object). Can someone help me starting this? Maybe some tutorials I haven't found? Any help will be appreciated.
zlib, which is already there, provides the raw decompression and CRC calculation engines. From there you can write your own code to interpret the zip file structure, which is documented in the PKWare appnote. It is relatively straightforward.
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?
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.
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.
I am working on a GWT project which has to run on phones,
The project is required to parse large xml files and since phones are tight on memory i am refraining from using the XML DOm parger bundled with GWT.
In my view the Pull Parser will be apt here. Is there a GWT implementation of the Pull Parser?? It will help reduce the memory required for parsing large XML files...
Thanks,
Karthik.
If you want to parse large files of xml on phones, you will likely hit memory limits of different phones pretty early.
Maybe there is an alternative approach (parse the files server side) and give the relavant information to the phones in a faster format like json.
I'll agree... JSON seems like a good solution!!! did some digging and the following link also shows how to parse and convert json objects to java for GWT coding
http://code.google.com/webtoolkit/doc/1.6/tutorial/JSON.html
I was just wondering how I can download a .webarchive from my UIWebView using ASIHTTPRequest. I've looked at their documentation but unfortunately, it doesn't mention anything about saving web archives.
I noticed that this app saves .webarchives to the iOS device and loads them.
To quote http://en.wikipedia.org/wiki/Webarchive :
"The webarchive format is a concatenation of source files with
filenames saved in the binary plist format using NSKeyedEncoder"
As jbat100 mentions, the ASIWebPageRequest code is likely to be a useful starting point - you'll need to write code to do the saving of the files into the binary plist format yourself.
please help me to understand that which library will be the best to extract .tar files in an iphone application.
on googling i have found in few posts that libacrchive can be used but another posts says that it will be problematic if you go to upload your app on App store.
Please suggest a suitable library for this purpose.
I write a lib exactly for that: extracting standard tar file without zlib compression.
https://github.com/mhausherr/Light-Untar-for-iOS
My lib take just few lines when libarchive heights 4.7Mb.
Full explanation here: http://blog.octo.com/en/untar-on-ios-the-pragmatic-way/