{ "id": "93359", "key": "TIMOB-9590", "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": "13574", "description": "Sprint 2012-15 Core", "name": "Sprint 2012-15 Core", "archived": true, "released": true, "releaseDate": "2012-07-30" }, { "id": "14096", "description": "Release 2.1.2", "name": "Release 2.1.2", "archived": true, "released": true, "releaseDate": "2012-08-31" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-08-11T17:46:05.000+0000", "created": "2012-06-15T21:54:09.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "SupportTeam", "core", "module_network", "parity", "qe-manualtest", "qe-port" ], "versions": [ { "id": "13273", "description": "Release 2.0.2", "name": "Release 2.0.2", "archived": false, "released": true, "releaseDate": "2012-05-31" }, { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" } ], "issuelinks": [ { "id": "19003", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "97635", "key": "TIMOB-10036", "fields": { "summary": "iOS: HTTPClient does not support sending TiFile object as documentation states", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-08-11T17:56:13.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": "When I run the below code on Android, the image is not uploaded, rather a 15 byte text file with the following text:\r\n[object TiBlob] \r\nThe code below runs fine on iOS, the image uploads successfully.\r\nh4. Repo Steps\r\n1. Run the given code sample in your app.js\r\n2. Click upload image button. \r\n3. It will then display the URL to the uploaded image.\r\n4. For Android, you have to load the link in a browser and Save as.\r\n5. Then change the extension to .txt to see its just a text file with the [object TiBlob] text.\r\n\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Win 1',\r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar img = Ti.UI.createImageView({\r\n\timage: 'http://www.guestassist.net/images/logo.png',\r\n\twidth: 229,\r\n\theight: 66,\r\n\ttop: 20\r\n});\r\n\r\nvar b1 = Ti.UI.createButton({\r\n\ttitle: 'upload image',\r\n\twidth: 200,\r\n\theight: 40,\r\n\ttop: 100\r\n});\r\n\r\nb1.addEventListener('click', uploadImage);\r\n\r\nvar link = Ti.UI.createTextField({\r\n\tvalue: '(url will show here)',\r\n\ttop: 160,\r\n\tleft: 10,\r\n\tright: 10,\r\n\theight: 60,\r\n\tbackgroundColor: 'white',\r\n\tborderColor: '#dddddd',\r\n\tborderWidth: 1,\r\n\tfont: {\r\n\t\tfontSize: 13\r\n\t}\r\n});\r\n\r\nwin1.add(img);\r\nwin1.add(b1);\r\nwin1.add(link);\r\nwin1.open();\r\n\r\nfunction uploadImage()\r\n{\r\n\tvar http = Ti.Network.createHTTPClient({\r\n\t\tonerror: function(e) {\r\n\t\t\tif (JSON.stringify(e).search('The request timed out') >= 0)\r\n\t\t\t{\r\n\t\t\t\tTi.API.info('timeout');\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tTi.API.info('error');\r\n\t\t\t}\r\n\t\t},\r\n\t\tonload: function(e) {\r\n\t\t\tTi.API.info('success!');\r\n\t\t},\r\n\t\tenableKeepAlive: false,\r\n\t\ttimeout: 360000\r\n\t});\r\n\t\r\n\t\r\n\tTi.App.idleTimerDisabled = true;\r\n\tvar d = new Date();\r\n\tvar raw = d.getTime();\r\n\tvar filename = raw + '.png';\r\n\t\r\n\tvar f = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory + '/' + filename);\r\n\tf.write(img.toBlob());\r\n\t\r\n\tvar uploadFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, filename);\r\n\tif (!uploadFile.exists()) { alert('file not found'); return false; }\r\n\tvar fileContents = uploadFile.read();\r\n\tvar curDate = 'Wed, 19 June 2011 10:00:00 -0500'; // hard coding date in AWS format for testing\r\n\tvar fileURL = 'https://s3.amazonaws.com/ga-testbucket/images/' + filename;\r\n\t\t\t\r\n\thttp.open('PUT', fileURL, false);\r\n\thttp.setRequestHeader('Content-Type', fileContents.mimeType);\r\n\tif (Ti.Platform.osname != 'android')\r\n\t{\r\n\t\thttp.setRequestHeader('Content-Length', uploadFile.size);\r\n\t}\r\n\thttp.setRequestHeader('Host', 's3.amazonaws.com');\r\n\thttp.setRequestHeader('Date', curDate);\r\n\thttp.setRequestHeader('x-amz-acl', 'public-read');\r\n\thttp.send(fileContents);\r\n\t\r\n\talert('image uploaded!');\r\n\tlink.value = fileURL;\r\n}\r\n{code} ", "attachment": [], "flagged": false, "summary": "Android: Using HTTPClient to PUT an image on Android uploads 15 bytes of text", "creator": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "android 2.2.2\r\nLG Optimus V\r\nTi SDK 2.0.2.GA", "comment": { "comments": [ { "id": "198824", "author": { "name": "mross@qtags.com", "key": "mross@qtags.com", "displayName": "Mark Ross", "active": true, "timeZone": "America/Chicago" }, "body": "There is a forum discussion about this issue as well. Although not the original poster's issue, the Android PUT issue is discussed in the comments:\r\n\r\nhttp://developer.appcelerator.com/question/120366/rest-put-to-aws-s3----works-on-ios-not-android\r\n\r\n", "updateAuthor": { "name": "mross@qtags.com", "key": "mross@qtags.com", "displayName": "Mark Ross", "active": true, "timeZone": "America/Chicago" }, "created": "2012-06-16T07:05:26.000+0000", "updated": "2012-06-16T07:05:26.000+0000" }, { "id": "208471", "author": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test case #2 (sends TiFile instead of TiBlob):\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Win 1',\r\n backgroundColor:'#fff'\r\n});\r\n \r\nvar img = Ti.UI.createImageView({\r\n image: 'http://www.guestassist.net/images/logo.png',\r\n width: 229,\r\n height: 66,\r\n top: 20\r\n});\r\n \r\nvar b1 = Ti.UI.createButton({\r\n title: 'upload image',\r\n width: 200,\r\n height: 40,\r\n top: 100\r\n});\r\n \r\nb1.addEventListener('click', uploadImage);\r\n \r\nvar link = Ti.UI.createTextField({\r\n value: '(url will show here)',\r\n top: 160,\r\n left: 10,\r\n right: 10,\r\n height: 60,\r\n backgroundColor: 'white',\r\n borderColor: '#dddddd',\r\n borderWidth: 1,\r\n font: {\r\n fontSize: 13\r\n }\r\n});\r\n \r\nwin1.add(img);\r\nwin1.add(b1);\r\nwin1.add(link);\r\nwin1.open();\r\n \r\nfunction uploadImage()\r\n{\r\n var http = Ti.Network.createHTTPClient({\r\n onerror: function(e) {\r\n if (JSON.stringify(e).search('The request timed out') >= 0)\r\n {\r\n Ti.API.info('timeout');\r\n }\r\n else\r\n {\r\n Ti.API.info('error');\r\n }\r\n },\r\n onload: function(e) {\r\n Ti.API.info('success!');\r\n },\r\n enableKeepAlive: false,\r\n timeout: 360000\r\n });\r\n \r\n \r\n Ti.App.idleTimerDisabled = true;\r\n var d = new Date();\r\n var raw = d.getTime();\r\n var filename = raw + '.png';\r\n \r\n var f = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory + '/' + filename);\r\n f.write(img.toBlob());\r\n \r\n var uploadFile = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, filename);\r\n if (!uploadFile.exists()) { alert('file not found'); return false; }\r\n var fileContents = uploadFile.read();\r\n var curDate = 'Wed, 19 June 2011 10:00:00 -0500'; // hard coding date in AWS format for testing\r\n var fileURL = 'https://s3.amazonaws.com/ga-testbucket/images/' + filename;\r\n \r\n http.open('PUT', fileURL, false);\r\n http.setRequestHeader('Content-Type', fileContents.mimeType);\r\n if (Ti.Platform.osname != 'android')\r\n {\r\n http.setRequestHeader('Content-Length', uploadFile.size);\r\n }\r\n http.setRequestHeader('Host', 's3.amazonaws.com');\r\n http.setRequestHeader('Date', curDate);\r\n http.setRequestHeader('x-amz-acl', 'public-read');\r\n http.send(uploadFile); // TiFile\r\n \r\n alert('image uploaded!');\r\n link.value = fileURL;\r\n}\r\n{code}", "updateAuthor": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-19T10:36:26.000+0000", "updated": "2012-07-19T10:36:26.000+0000" }, { "id": "208474", "author": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR pending https://github.com/appcelerator/titanium_mobile/pull/2607", "updateAuthor": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-19T10:40:18.000+0000", "updated": "2012-07-19T10:40:18.000+0000" }, { "id": "214256", "author": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Backport PR https://github.com/appcelerator/titanium_mobile/pull/2736", "updateAuthor": { "name": "mstepanov", "key": "mstepanov", "displayName": "Max Stepanov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-13T21:44:45.000+0000", "updated": "2012-08-13T21:44:45.000+0000" }, { "id": "214503", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening to update FixVersion 2.1.2\r\n", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-14T17:21:20.000+0000", "updated": "2012-08-14T17:21:20.000+0000" }, { "id": "215149", "author": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as fixed.\r\nTested and verified on:\r\nTitanium Studio, build: 2.1.1.201208091713\r\nTitanium SDK, build: 2.1.2.v20120816171609\r\nDevices: Nexus 7 tab (4.1.1)", "updateAuthor": { "name": "tsmolich", "key": "tsmolich", "displayName": "Tamila Smolich", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-20T10:43:38.000+0000", "updated": "2012-08-20T10:43:38.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }