how to download zip files from webview into iphone?
I plan to let users download their own files and stored them inside iPhone. The process is typically:
- ap开发者_JS百科p file into cloud app convert zip file.
- iPhone present a web page by UIWebView, in which there are one link to .zip files the user browser the page and click on one of the .zip file link *download zip file in cloud app ,how to open? *zip file download in iphone device possible or not possible, any body know help me!
1/ Declare a delegate for your webview.
2/ Implement ShouldStartLoadWithRequest delegate method:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
3/ return NO in this delegate, but use the request url to download the zip file using NSURLConnection.
4/Use a zip library to decompress the zip file.
For example ZipArchive.
Check ASIHTTPRequest
"ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications."
Look for: "Using gzip to handle compressed response data"
精彩评论