{ "id": "154039", "key": "AC-1172", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2016-01-07T08:24:05.000+0000", "created": "2015-12-25T21:18:01.000+0000", "labels": [ "android", "defect", "httpclient" ], "versions": [], "issuelinks": [], "assignee": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "updated": "2016-03-08T07:37:32.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "attachment": [ { "id": "57846", "filename": "IMAG0443.jpg", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-25T20:59:56.000+0000", "size": 1886092, "mimeType": "image/jpeg" }, { "id": "57844", "filename": "post-as-base64.txt", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-25T21:05:13.000+0000", "size": 2647930, "mimeType": "text/plain" }, { "id": "57845", "filename": "post-as-binary.txt", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-25T21:01:58.000+0000", "size": 3228034, "mimeType": "text/plain" }, { "id": "57859", "filename": "post-with-both.txt", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-30T22:38:50.000+0000", "size": 5742965, "mimeType": "text/plain" } ], "flagged": false, "summary": "Android HTTPClient: POST with image encoded as base64 sent as GET", "creator": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "environment": null, "comment": { "comments": [ { "id": "373626", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "What happens when you keep both of them?\r\n{code}\r\n var data = {\r\n\r\n \"entry.id\": entryBean.id\r\n\r\n , \"_eventName\": \"uploadPhoto\"\r\n\r\n , \"imageData\": selectedImage\r\n\r\n , encodedImage: Ti.Utils.base64encode(selectedImage).toString()\r\n\r\n , \"caption\": $.caption.value\r\n\r\n , \"fileName\": getFileNameFrom(selectedImage)\r\n\r\n };\r\n{code}\r\n\r\nOr try to make a blob of the image and then try base64encode.\r\n\r\n{code}\r\nimage=selectedImage.toBlob(); \r\n...\r\nencodedImage: Ti.Utils.base64encode(image).toString()\r\n{code}\r\nReply with your response. Thanks.\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2015-12-30T10:34:54.000+0000", "updated": "2015-12-30T10:34:54.000+0000" }, { "id": "373645", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "body": "\r\nFirst, I noticed that the {{encodedImage}} key on the {{data}} object wasn't in quotes like the others, so I changed it. Doesn't seem to have made a difference.\r\n\r\nAnyway, when I sent the image as both binary data and as base64 like this:\r\n\r\n{code:javascript}\r\n var data = {\r\n \"entry.id\": entryBean.id\r\n , \"_eventName\": \"uploadPhoto\"\r\n , \"imageData\": selectedImage\r\n , \"encodedImage\": Ti.Utils.base64encode(selectedImage).toString()\r\n , \"caption\": $.caption.value\r\n , \"fileName\": getFileNameFrom(selectedImage)\r\n };\r\n{code}\r\n\r\nThe data was correctly sent as a {{POST}}. See attachment post-as-both.txt.\r\n\r\nWhen I tried your suggestion of converting to a blob like this:\r\n\r\n{code:javascript} \r\nvar data = {\r\n \"entry.id\": entryBean.id\r\n , \"_eventName\": \"uploadPhoto\"\r\n , \"imageData\": selectedImage\r\n //, \"encodedImage\": Ti.Utils.base64encode(selectedImage).toString()\r\n , \"encodedImage\": Ti.Utils.base64encode(selectedImage.toBlob()).toString()\r\n , \"caption\": $.caption.value\r\n , \"fileName\": getFileNameFrom(selectedImage)\r\n };\r\n{code}\r\n\r\nI get a runtime error that says this:\r\n\r\nMessage: Uncaught TypeError: Object [object TiBlob] has no method 'toBlob'\r\n\r\nSource: encodedImage: TiUtils.base64encode(selectedImage.toBlob()).toStri\r\n\r\nApparently {{selectedImage}} is already a Blob.\r\n\r\nDoes that help?", "updateAuthor": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2015-12-30T22:37:41.000+0000", "updated": "2015-12-30T22:37:41.000+0000" }, { "id": "373988", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, It looks like when you tried to sent the image as both binary data and as base64, The data was correctly sent as a POST. Which I think resolves your issue. We will resolve this issue. If you have any further requirement please let us know. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-01-07T06:50:59.000+0000", "updated": "2016-01-07T06:50:59.000+0000" }, { "id": "374057", "author": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "body": "\r\nHi, it's definitely *NOT* working correctly. The problem is that when sending the image as base64 (and only base64), the data is sent as a GET instead of a POST. See attachment post-as-base64.txt.\r\n\r\nMy apologies, but I should have mentioned earlier that I do explicitly set the request to be a POST:\r\n\r\n{code:javascript}\r\n var data = {\r\n \"entry.id\": entryBean.id\r\n , \"_eventName\": \"uploadPhoto\"\r\n , \"imageData\": selectedImage\r\n // , encodedImage: Ti.Utils.base64encode(selectedImage).toString()\r\n , \"caption\": $.caption.value\r\n , \"fileName\": getFileNameFrom(selectedImage)\r\n };\r\n \r\n var options = http.standardOptions();\r\n options.url = \"mobile/entry/EntryImage.action?_eventName=uploadPhoto\";\r\n options.method = \"POST\";\r\n options.data = data;\r\n options.onComplete = function(response) {\r\n Ti.API.info(\"made it to PhotoUpload onComplete!!!!\");\r\n onUploadComplete(response);\r\n };\r\n options.onLoginSuccess = closeWindow;\r\n \r\n http.send(options);\r\n{code}\r\n\r\nYes, when I sent the image as both binary and base64 the request was correctly sent as a POST. The issue is that when the image is sent *only* as base64, it's sent as a GET.\r\n\r\nLet me know what you find. Thank you!!!", "updateAuthor": { "name": "ryan@asleson.net", "key": "ryan@asleson.net", "displayName": "Ryan Asleson", "active": true, "timeZone": "America/Chicago" }, "created": "2016-01-08T02:39:49.000+0000", "updated": "2016-01-08T02:39:49.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }