{ "id": "62290", "key": "TIMOB-1658", "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": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-02-11T21:20:28.000+0000", "created": "2011-04-15T02:58:37.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "api", "exalture", "qe-closed-3.2.2", "supportTeam" ], "versions": [ { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-03-10T09:28:54.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "On the iPhone, Titanium.Filesystem.File.write always returns\r\nfalse when writing binary data to files. It works correctly for\r\ntext data. (There doesn't seem to be a problem on Android.)\r\n\r\n{code}\r\nvar appDirName = Titanium.Filesystem.applicationDataDirectory;\r\nvar txtFile = Titanium.Filesystem.getFile(appDirName, 'foobar.txt');\r\nvar binFile = Titanium.Filesystem.getFile(appDirName, 'foobar.bin');\r\n\r\nvar text = \"Sudo make me a sandwich.\";\r\n\r\nif (!txtFile.exists()) {\r\n Titanium.API.debug(\"File \" + txtFile.name + \" does not exist yet.\");\r\n}\r\n\r\nif (!binFile.exists()) {\r\n Titanium.API.debug(\"File \" + binFile.name + \" does not exist yet.\");\r\n}\r\n\r\nif (txtFile.write(text)) {\r\n Titanium.API.debug(\"I successfully wrote text to the file.\");\r\n} else {\r\n Titanium.API.debug(\"I was not able to write text to the file. Oh no!\");\r\n}\r\n\r\nvar blob = Titanium.Utils.base64decode(text); // make some bin data\r\n\r\nif (binFile.write(blob)) {\r\n Titanium.API.debug(\"I successfully wrote a blob to the file.\");\r\n} else {\r\n Titanium.API.debug(\"I was not able to write a blob to the file. Oh no!\");\r\n}\r\n\r\n// Do they exist now?\r\nif (txtFile.exists()) {\r\n Titanium.API.debug(txtFile.name + \" exists, contents: \" + txtFile.read());\r\n}\r\n\r\nif (binFile.exists()) {\r\n // Note: Titanium.Filesystem.File.size attribute not mentioned in the API docs\r\n Titanium.API.debug(binFile.name + \" exists, size: \" + binFile.size);\r\n}\r\n{code}\r\n\r\n{html}\r\n

iPhone:

\r\n
\r\n[DEBUG] File foobar.txt does not exist yet.\r\n[DEBUG] File foobar.bin does not exist yet.\r\n[DEBUG] I successfully wrote text to the file.\r\n[DEBUG] I was not able to write a blob to the file. Oh no!\r\n[DEBUG] foobar.txt exists, contents: Sudo make me a sandwich.\r\n[DEBUG] foobar.bin exists, size: 15\r\n
\r\n

Android:

\r\n
\r\nD/TiAPI   (  532): (kroll$1) [615,1099] File foobar.txt does not exist yet.\r\nD/TiAPI   (  532): (kroll$1) [21,1120] File foobar.bin does not exist yet.\r\nD/TiAPI   (  532): (kroll$1) [154,1274] I successfully wrote text to the file.\r\nD/TiAPI   (  532): (kroll$1) [725,1999] I successfully wrote a blob to the file.\r\nD/TiAPI   (  532): (kroll$1) [87,2086] foobar.txt exists, contents: Sudo make me a sandwich.\r\nD/TiAPI   (  532): (kroll$1) [18,2104] foobar.bin exists, size: 15\r\n
{html}", "attachment": [], "flagged": false, "summary": "iOS: Ti.File.write always returns false for binary data", "creator": { "name": "zcopley", "key": "zcopley", "displayName": "zcopley", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "zcopley", "key": "zcopley", "displayName": "zcopley", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK: 3.2.0.GA\r\nTitanium CLI: 3.2.0, \r\nIOS Simulator 7.0.3 \r\n", "comment": { "comments": [ { "id": "126297", "author": { "name": "ctredway1", "key": "ctredway1", "displayName": "ctredway", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I confirmed this running 1.4.1 on iOS 4.

{html}", "updateAuthor": { "name": "ctredway1", "key": "ctredway1", "displayName": "ctredway", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:58:38.000+0000", "updated": "2011-04-15T02:58:38.000+0000" }, { "id": "171435", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Bug is still valid, occurs in:\r\nTiMOB sdk version: 1.7.2, 1.8.0.v20111103144656\r\nStudio version: 1.0.7.201111022004\r\nOS version: Mac OS X Lion\r\nDevices tested on: ipod 4.0.2, iphone 5.0", "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-11-03T16:55:17.000+0000", "updated": "2011-11-03T16:55:17.000+0000" }, { "id": "183623", "author": { "name": "oborseth", "key": "oborseth", "displayName": "Owen Borseth", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Still a bug as of today with the latest SDK", "updateAuthor": { "name": "oborseth", "key": "oborseth", "displayName": "Owen Borseth", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-02-17T09:08:37.000+0000", "updated": "2012-02-17T09:08:37.000+0000" }, { "id": "209441", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Still valid SDK 2.2.0.f9e938d", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-25T16:10:34.000+0000", "updated": "2012-07-25T16:10:34.000+0000" }, { "id": "214794", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Still reproducible using TiSDK 2.2.0v20120816015712 on the iOS simulator. ", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-08-16T10:39:19.000+0000", "updated": "2012-08-16T10:39:19.000+0000" }, { "id": "237416", "author": { "name": "usr743n", "key": "usr743n", "displayName": "Hans Joachim", "active": true, "timeZone": "Europe/Berlin" }, "body": "I can confirm this bug. But why has it priority \"Medium\" only?", "updateAuthor": { "name": "usr743n", "key": "usr743n", "displayName": "Hans Joachim", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-02-06T11:01:51.000+0000", "updated": "2013-02-06T11:01:51.000+0000" }, { "id": "292454", "author": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "body": "This issue can't reproduced with TISDK 3.2 or higher. Therefore, marking is resolved.", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-02-11T21:20:28.000+0000", "updated": "2014-02-11T21:20:28.000+0000" }, { "id": "296279", "author": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Ti.File.write(binary) returns true, tested using the above code, hence closing the issue\r\n\r\nVerified the fix on:\r\nDevice : iPhone 5s , iOS version : 7.1\r\nSDK: 3.2.2.v20140221161255\r\nCLI version : 3.2.1\r\nOS : MAC OSX 10.9\r\nAlloy: 1.3.1\r\nACS: 1.0.14\r\nnpm:1.3.2\r\nAppcelerator Studio, build: 3.2.2.201402280732\r\ntitanium-code-processor: 1.1.0\r\nXCode : 5.1 Beta 5", "updateAuthor": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2014-03-10T09:28:42.000+0000", "updated": "2014-03-10T09:28:42.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }