{ "id": "62682", "key": "TIMOB-2050", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:55.000+0000", "created": "2011-04-15T03:09:03.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "android", "httpclient", "xhr" ], "versions": [], "issuelinks": [], "assignee": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:57:55.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Seems like Ruby on Rails doesn't like a Content-Type header\nalong side a form-data multipart. It will attempt to convert normal\nform/data key/value pairs into a File Attachment (containing the\nvalue) instead.

\n

In iPhone, this Content-Type header is not present and it works\nfine. So, for normal fields, we should be suppressing this header\nfield to have the same behavior as iOS. Removing this field causes\nit to work OK.

{html}", "attachment": [], "flagged": false, "summary": "Android: POST with file/blob parameter will cause issue with rails", "creator": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "127361", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [410b2dea89339e948cec2626e1c93822ed556048])\n[#2050 state:fixed-in-qa] fixed android issue\nrelated to POST with Content-Type for a plain form/data field\n\nhttp://github.com/appcelerator/titanium_mobile/commit/410b2dea89339...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:04.000+0000", "updated": "2011-04-15T03:09:04.000+0000" }, { "id": "127362", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

How can Thomas reproduce this to move it to a resolved\nstate?

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:04.000+0000", "updated": "2011-04-15T03:09:04.000+0000" }, { "id": "127363", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

the easiest way is to:

\n
{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:04.000+0000", "updated": "2011-04-15T03:09:04.000+0000" }, { "id": "127364", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

Thomas, I can also share the customer client code if you'd\nlike.

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:04.000+0000", "updated": "2011-04-15T03:09:04.000+0000" }, { "id": "127365", "author": { "name": "kevinwhinnery", "key": "kevinwhinnery", "displayName": "kevinwhinnery", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

I verified that this works on 1.5.0, Android 2.2 and 2.1. Here's\nmy Rails controller code:

\n
\nclass UploadController < ApplicationController\n  def doit\n    render :text => \"got #{params[:file]} and also #{params[:hello]}, request:\\n#{request}\"\n  end\nend\n
\n

And the Titanium code:

\n
\nvar xhr = Titanium.Network.createHTTPClient();\nvar f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'KS_nav_ui.png');
\n
\n\n\n
\nxhr.onerror = function(e) {
\n
\n\n\n
\n
\n
\nTi.API.info('IN ERROR ' + e.error);\n
\n
\n\n\n
\n};\nxhr.onload = function(e) {\n\n
\n
\nTi.API.info('IN ONLOAD ' + this.responseText);\n
\n
\n\n\n
\n};\n// open the client\nxhr.open('POST','http://10.0.1.91:3000/upload/doit');\n\n
\n// send the data\nxhr.send({image:f,hello:'hello world!',password:'sanford1000',message:'check me out'});\n
{html}", "updateAuthor": { "name": "kevinwhinnery", "key": "kevinwhinnery", "displayName": "kevinwhinnery", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:04.000+0000", "updated": "2011-04-15T03:09:04.000+0000" }, { "id": "127366", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

closing due to Kevins awesomeness

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:09:05.000+0000", "updated": "2011-04-15T03:09:05.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }