{ "id": "62236", "key": "TIMOB-1604", "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": "2012-05-14T14:49:57.000+0000", "created": "2011-04-15T02:57:11.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-05-14T14:49:58.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}

You cannot use Titanium.Utils.base64encode &\r\nTitanium.Utils.base64decode successfully to round-trip the encoding\r\n/ decoding of a blob. In other words, you don't get back the same\r\nset of bytes that you originally started with.

\r\n

Failcase app.js (make sure you have KS_nav_ui.png in your\r\nResources folder; it's there by default with new projects):

\r\n
\r\n\r\nvar win = Ti.UI.createWindow({fullscreen: true, exitOnClose:true});\r\n\r\nvar file = Ti.Filesystem.getFile('KS_nav_ui.png');\r\n\r\nvar blob1 = file.read();\r\nvar base64 = Ti.Utils.base64encode(blob1);\r\nvar blob2 = Ti.Utils.base64decode(base64);\r\n\r\nvar thumbnail1 = Titanium.UI.createView({left: 0, top: 0, width: 46, height: 43});\r\nthumbnail1.backgroundImage = 'KS_nav_ui.png'; // the orig, which obviously works    \r\nvar thumbnail2 = Titanium.UI.createView({left: 56, top: 0, width: 46, height: 43});\r\nvar thumbnail3 = Titanium.UI.createView({left: 112, top: 0, width: 46, height: 43});\r\nwin.add(thumbnail1); win.add(thumbnail2); win.add(thumbnail3);\r\n\r\nvar tempDir = Titanium.Filesystem.createTempDirectory();\r\ntempDir.createDirectory();\r\n\r\n// Blob from original file\r\nvar file1 = Titanium.Filesystem.getFile(tempDir.nativePath, 'file1.png');\r\nfile1.write(blob1);\r\nthumbnail2.backgroundImage = file1.nativePath;\r\n\r\n// Base64 encoded-then-decoded blob\r\nvar file2 = Titanium.Filesystem.getFile(tempDir.nativePath, 'file2.png');\r\nfile2.write(blob2);\r\nthumbnail3.backgroundImage = file2.nativePath;\r\n\r\nwin.open();\r\n
\r\n

You should see three identical images when that runs. Instead,\r\nyou'll see only two.

{html}", "attachment": [], "flagged": false, "summary": "Android: base64 encoding/decoding of Blob cannot be round-tripped successfully", "creator": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "126174", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [fd880341bc564607ed68650fd73660f57131d23f])\n[#1604 state:fixed-in-qa] When base64encoding a\nblob, don't force it to its string representation if you don't have\nto. That makes it unusable for binary files, images, etc. \nhttp://github.com/appcelerator/titanium_mobile/commit/fd880341bc564...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:11.000+0000", "updated": "2011-04-15T02:57:11.000+0000" }, { "id": "126175", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

fixed on android using 1.4.1.ca7b78 device an simulator. Opening\na new issue for iOS to have functional parity.

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:12.000+0000", "updated": "2011-04-15T02:57:12.000+0000" }, { "id": "126176", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

#1611 for iOS

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:12.000+0000", "updated": "2011-04-15T02:57:12.000+0000" }, { "id": "171157", "author": { "name": "pseda", "key": "pseda", "displayName": "Patrick Seda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopen via customer request.\r\n\r\nh4. Associated Helpdesk Ticket\r\nhttp://appc.me/c/APP-486271", "updateAuthor": { "name": "pseda", "key": "pseda", "displayName": "Patrick Seda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-02T07:44:36.000+0000", "updated": "2011-11-02T07:44:36.000+0000" }, { "id": "171188", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Looks like the docs need to be updated. base64encode() returns a TiBlob, and you will need to call getText() on TiBlob to get the string value", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-02T09:56:45.000+0000", "updated": "2011-11-02T09:56:45.000+0000" }, { "id": "194720", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Tested with 2.0.1GA2 on a Samsung Galaxy S2 (2.3.6). Unable to reproduce the issue. Ticket closed.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-05-14T14:49:58.000+0000", "updated": "2012-05-14T14:49:58.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }