I got a weird problem, I have also looked at other solutions and also looked at the ASIHTTPRequest
github page.
I am using ASIHTTPRequest
library and ASIFormDataRequest
to upload images to my Symfony web server.
I have two problems:
1) Slow upload
I am not sure what it is but for uploading an image that has image data size = 244671
I assume that's around 245 KB.
It's taking longer than 15 seconds to upload.
My iPhone is on Wifi connection in the City area.
2) Server request timeout even if success
I am receiving a server time out error despite the data being fully uploaded, the image appears on my server correctly.
The code I am using is:
// ------------------------------------------------------------------------------
// saving a compressed version of the file to disk to upload the file
// rather than using an uncompressed NSData which will take longer to upload
// ------------------------------------------------------------------------------
[imgData writeToFile:[MediaDirectory mediaPathForFileName:strFilename] atomically:YES];
[MediaDirectory addSkipBackupAttributeToFile:strFilename];
[request setFile:[MediaDirectory mediaPathForFileName:strFilename] withFileName:strFilename andContentType:@"image/png" forKey:@"file"];
My image is not some gigantic image, it's only 373 x 500 pixels.
Any ideas?
I don't want to disable the buffer size trick thing as suggested in ASIHTTPRequest
bug tracker if there is a proper way to solve it.
I've found a new library called MKNetworkKit
which handles the POST request properly and provides the necessary POST key field which I need to set for my POSt request.
Might go with MKNetworkKit from now on if I find it stable enough.
I was relunctant to go with AFNetworking because of previous experience with bugs when trying to POST email addresses and also AFNetworking did not allow me to set the POST value key for the POST request.
Hope that helps anyone else who's experience the same problem.