downloading big size(In MB) .txt files using NSURLConnection - iphone

I'm downloading .txt files using NSURLConnection. Small size (in KB's) files are downloading perfectly but when i downloading big size(In MB) file, it always downloaded with corrupt data.
Sometimes big size .txt files are downloaded. But when i fetch those .txt file programmatically, it shows null content in it.
Please help.....
Thanks in advance.

You should check out the ASIHTTPRequest wrapper classes for HTTP request. They make the download of big sized files easy as they allow to download the files directly to the file system. I am currently using these wrapper classes on a project and I can assure you that they make your life a lot easier.

Related

File Uploading in Sakai

I want to know if there is a 'right' way to make file uploads through custom tools.
I've seen the https://confluence.sakaiproject.org/display/BOOT/File+Uploads+with+RSF guide and it seens ok, but It stops with the file in memory with no further info. I can built a random file upload code but I want to make it Sakai-friendly (Using ContentHosting and Resources service?)
Any hints?
Thanks
The link you provided for the first part is a good example of how to get the upload initially processed. Going through RequestFilter will get your files validated, but you can use whatever method you want to upload it.
For the second part, I'd look at the ContentHosting webservice (createContentItem) for an example of how to add a file from a byte[] in memory after you've uploaded it.
These methods in ContentHostingService also accept InputStream as a parameter as of 2.7 (KNL-325), so you don't have to store the entire file in memory and can stream it as you're uploading, which you should do if the files are of any reasonable size.

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.

Caching UIWebview from local loaded files

I have a uiwebview which loads documents from local file system. Some of the images on these HTML files are 2 mb. I wanted to cache those images or the whole HTML.
What is the best way to accomplish or is this even something I should consider?
Thanks for all your help.
It sounds like your best option would be to cache the large images and put them in the bundle at compile time. You could then change the URL's to those large images in your HTML to file URL's pointing to the files in the bundle.

Library for decoding a zip file in chunk

Hi fellow overflowers,
i need to decode a large zip file (around 20mb) on the ipad. Is there a way to parse the zip file in chunks?
Ideally i would like to pass the decoder (let's say) 512k of data at time, and get back a chunk of decoded data, because i have a feeling that loading all the file in memory and then decompress it could lead to severe memory problems.
A pointer to some incremental decoding libraries would be nice!
Thanks,
Giuliano
UPDATE: the link provided by Matt in his answer worked fine for me ;)
Have you tried objective-zip? http://code.google.com/p/objective-zip/
There's an example near the bottom of http://code.google.com/p/objective-zip/wiki/GettingStarted, showing how to read big files.
I have achieve unzipping files using GCD. This examples uses unzipping of files in different thread and when done it notifies main thread and main thread updates the information.... Hope this may also be solution to your problem....
http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorial

how to unzip an image in the iphone code

to unzip an image file sent after gzipping it on the server side i know i have to use gzopen.
i want to know if there is a more direct and simple way to do this with 'compressiontype' or something related that once i have the 'zipped image data' received from the server using NSURLconnection can i load an imageview using an easier method.
The zip library you are using will dictate how you can unzip the received data.
I haven't found a zip library that will unzip directly from an NSData object; I've found that the data needs to be written to a file (in the documents directory) and then unzipped.
I use 'ziparchive' available http://code.google.com/p/ziparchive/wiki/PageName