{ "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\nAndroid:
\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.