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
Related
I want to compress a file before uploading it on server in sapui5 (image(png/jpeg/jpg)/pdf/). I want to upload a large files but i want to compress that file before uploading. Please suggest me solution ?
I think you will not be able to do it with instant upload. Instead, you should obtain the file from the change event of the file uploader (check out the change event, it has a files parameter).
You can then use that file object together with the zip.js library to create an in-memory zip and save it into e.g. a Blob. Afterwards you simply send the blob into a POST request (e.g. look at How can javascript upload a blob?). Maybe you should also provide some file-uploading specific headers (like the Slug).
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.
After learning the basics from Apple's SimpleFTPSample project, I'm trying to append a string to the end of a .txt file on my FTP server. I successfully managed to overwrite an existing file with a custom string, but I suspect that the kCFStreamPropertyAppendToFile property that defines whether the file will be overwritten or appended is not available in iOS.
What is the recommended way to do so in iOS?
Eventually I ended up downloading the file's content using HTTP (it's much faster than FTP). Next, appending the string to the file's content and then uploading the file to the server using FTP.
This might not be the best solution, but it does solve the problem.
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'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.