Native swift zip decompression - swift

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.

Related

Uploading to specified target with jQuery fileupload?

I'm using jQuery fileupload on a site to upload a single file for processing. I've got a simple upload working based on the Basic Plus demo, but would like to upload files to a given path and filename on the server (independent of the filename on the client machine). It seems like this should be straightforward, but I'm having problems figuring it out or finding resources. Is this possible in jQuery fileupload? If so, can anybody point me in the right direction for how?
Thanks for your time!
Answered? Found some helpful information here on changing the filename of uploads.

Download and unpack a *.tgz file to a subdirectory of the Documents directory

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.

Acceptable library to extract .Tar files for an iphone application

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/

extract zlib file in iOS?

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

"Untar" file on iPhone

I'm writing an iPhone app which downloads a tar-gzipped file from a Webserver, then needs to unarchive this file so that it can be copied into the app's Documents folder.
I'm using tar/gzip because I want to download a whole bunch of small files in one HTTP request, to make everything nice and fast.
I've investigated solutions like http://www.feep.net/libtar/, but as a C/Objective-C newb, I can't get any of them to compile for the iPhone platform.
(I felt like I should just be able to do a system call to "tar -zxvf myfile.tar.gz", but it would appear it's not that easy!)
So is there a simple way to just un-tar a file on the iPhone? Or am I going about this all wrong, and is there a better way to do this?
Thanks in advance!
Nik
This blog post should help you:
http://blog.hawkey.org/?p=332
EDIT: Google cache version of the same page which actually links to a forum post here which links to a Google Code project here, containing some code which implements unzipping on iOS.
Here is a light untar library for iOS : https://github.com/mhausherr/Light-Untar-for-iOS
Complete blog post about the solution : http://blog.octo.com/en/untar-on-ios-the-pragmatic-way/
Hope this helps,
Vincent
I took a different approach by building libarchive and bz2lib as a static library for iOS. You can find it here:
http://github.com/davepeck/iOS-libarchive/