Hi there,
I have an app that allows you to take a picture, adjust the jpeg quality size (10-100%) and then send it to a server using ASIFormDataRequest (part of the ASIHTTPRequest implementation). This works fine over a network connection, but over the celluar network it appears to sit there for 5-10 minutes attempting to transmit the image post data, before failing (even with the quality at 10%).
On comparing this to the image uploads that the Twitter and Facebook apps provide (which take ~30 seconds to a minute) this isn't exactly ideal. I wondered if anyone could give me any advice about either how to speed up my data transfer, or monitor it so I can see exactly where the problem lies.
Once I get back to my mac laptop tonight I'll post a code snippet of exactly what it is I'm doing, in case that helps.
EDIT: Heres the code snippet:
NSURL *url = [NSURL URLWithString:@"...upload.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
NSString *fileName = [NSString stringWithFormat:@"%d", time];
...
float compressionRate = [userAccountView getCompressionRate];
NSLog(@"Compression rate: %.1f", compressionRate);
NSData *imageData = UIImageJPEGRepresentation(imageForView, compressionRate);
[request setData:imageData withFileName:fileName andContentType:@"image/jpeg" forKey:@"userfile"];
[request setDelegate:self];
[request startAsynchronous];
The .. code comment is where I just stick an 'uploading' image over the view. I suppose I could make the call synchronous as opposed to asynchronous, do you think that may improve performance? I have left it that way in case at a later stage I wanted to allow the user to do other bits while it is uploading.
Any advice would be great :)
Thanks,
Dan
EDIT:
Jesse, thanks for the comment - I added in [request setUploadProcessDelegate:self] and put in the required method to monitor the data that was being sent, and it all seemed to be sending okay.
JosephH - I have added in "[ASIHTTPRequest setShouldThrottleBandwidthForWWAN:YES]" as suggested, and have also added "set_time_limit(0);" into the PHP upload script (in case of timeouts) and now the data does seem to be sending and being retrieved over the cellular network, so horray! Am playing around now with file compressions etc. to find the best one for the best quality. ATM it seems like 0.3 is pretty good quality, and transfers in roughly 30 seconds or so, which is what I was looking for!
I was also incorrectly setting the compression rate, as I was using 10-100 as opposed to 0.0-1.0, so I have also corrected that.
Thanks for your quick help guys in solving my issue!!