Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP vs HTTP upload on iPhone

In my iPhone application I need to upload images to a server. I don't worry much about security and stuffs, just need a fast and reliable method. I can embed my image data on the HTTP post request, or I can create a FTP connection to the server (using the SimpleFTPSample from Apple). The disadvantage of each method is: - HTTP: time out if image too big without way of resuming, and no way to know the upload progress (%)? - FTP: sometimes I got NSStreamEventErrorOccurred and don't know why (when tested on device, on simulator it works great. So maybe 3G errors?)

My question is, do you have any experience with this problem (upload image to server)? What method do you recommend? FTP, HTTP or other method? Thanks in advance.

like image 736
iamj4de Avatar asked Dec 29 '25 02:12

iamj4de


2 Answers

Fast, Easy & reliable: ASIHTTPRequest and you can track upload progress.

like image 179
mracoker Avatar answered Dec 31 '25 16:12

mracoker


I finally continue to use HTTP, and use the following delegate method to track upload progress:

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite

totalBytesWritten / totalBytesExpectedToWrite gives me the upload percentage.

like image 22
iamj4de Avatar answered Dec 31 '25 15:12

iamj4de