[TIMOB-3328] xhr photo upload broken on device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-06-05T22:57:19.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | image, photo, upload |
Reporter | Brian |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T03:42:13.000+0000 |
Updated | 2017-06-05T22:57:19.000+0000 |
Description
Uploading a photo works maybe 1 out of 10 times. A perfect example is to load the Kitchen Sink app onto your iPhone and goto XHR -> file upload.
Our app uses this same approach and we get the same unfortunate failures. Our server throws the following error:
Status: 500 Internal Server Error bad content body
/usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/utils.rb:467:in `parse_multipart'
Please advise because this is extremely important to us and it seems to have been an issue for a few months because here is a post from someone experiencing a similar issue:
http://developer.appcelerator.com/question/95661/image-upload-image-files-null-over-3g-works-fine-over-wifi"> http://developer.appcelerator.com/question/95661/image-upload-image...
I just found that this issue is not just isolated to the device...it fails on the simulator too, just not as often.
I discovered that uploading to a server on your local computer from the simulator always works, so it seems to be only be an issue when uploading to a remote server.
Here is another post from Q&A that is experiencing the same issues:
http://developer.appcelerator.com/question/109191/file-upload-fail"> http://developer.appcelerator.com/question/109191/file-upload-fail
I discovered if you comment out these lines of code (201 - 203) in ASIFormDataRequest.m everything works just fine:
// if ([[self fileData] count] > 0) { // [self setShouldStreamPostDataFromDisk:YES]; // }
This seems to be related to a rack 1.1.0 parsing issue with rails 2.3.x that is supposed to be fixed in rails 3.x with rack 1.2.x, but if anyone is running rails 2.3.x they will encounter these problems and have to comment out the 3 lines of code above.
Also you may want to test this with Engine Yard since you are partnering with them.
Best,
Brian
I looked into the ASI framework some more and found that they recommend you set shouldAttemptPersistentConnection to NO. This seems to do the trick even better. So instead of commenting out lines (201 - 203) in ASIFormDataRequest.m, all you have to do is update the TiNetworkHTTPClientProxy.m on line 346 to [request setShouldAttemptPersistentConnection:NO];
Wow...just found the undocumented setting, "enableKeepAlive" for createHTTPClient. Doing the following fixes the issue:
xhr = Titanium.Network.createHTTPClient({
Please update the docs and let people know that when uploading images to set enableKeepAlive to false.
Confirmed, we're having these kind of issues w/ Google App Engine's Images API with weak cell signal / EDGE networks.
This version of Kitchen Sink is no longer supported.