{"action":"opened","issue":{"url":"https://api.github.com/repos/apache/cordova-plugin-file/issues/244","repository_url":"https://api.github.com/repos/apache/cordova-plugin-file","labels_url":"https://api.github.com/repos/apache/cordova-plugin-file/issues/244/labels{/name}","comments_url":"https://api.github.com/repos/apache/cordova-plugin-file/issues/244/comments","events_url":"https://api.github.com/repos/apache/cordova-plugin-file/issues/244/events","html_url":"https://github.com/apache/cordova-plugin-file/issues/244","id":352981584,"node_id":"MDU6SXNzdWUzNTI5ODE1ODQ=","number":244,"title":"File created for android are always empty","user":{"login":"lucabro81","id":7601609,"node_id":"MDQ6VXNlcjc2MDE2MDk=","avatar_url":"https://avatars2.githubusercontent.com/u/7601609?v=4","gravatar_id":"","url":"https://api.github.com/users/lucabro81","html_url":"https://github.com/lucabro81","followers_url":"https://api.github.com/users/lucabro81/followers","following_url":"https://api.github.com/users/lucabro81/following{/other_user}","gists_url":"https://api.github.com/users/lucabro81/gists{/gist_id}","starred_url":"https://api.github.com/users/lucabro81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucabro81/subscriptions","organizations_url":"https://api.github.com/users/lucabro81/orgs","repos_url":"https://api.github.com/users/lucabro81/repos","events_url":"https://api.github.com/users/lucabro81/events{/privacy}","received_events_url":"https://api.github.com/users/lucabro81/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-22T14:33:22Z","updated_at":"2018-08-22T14:33:22Z","closed_at":null,"author_association":"NONE","body":"I described the issue here:\r\nhttps://stackoverflow.com/q/51969064/1619070\r\n\r\nWhen I try to write a file with a correct blob nothing happen, I can see the file created but is empty and no error or exception or success event is fired\r\n\r\nthese are the function I've used\r\n\r\n```\r\nclass FileHelper {\r\n\r\n    public file:File;\r\n\r\n    constructor() {\r\n        this.file = new File();\r\n    }\r\n\r\n    public save(filename:string, dir:string, data:any):Promise<any> {\r\n\r\n        console.log(\"FileHelper.save filename\", filename);\r\n        console.log(\"FileHelper.save dir\", dir);\r\n        console.log(\"FileHelper.save data\", data);\r\n\r\n        return this.file\r\n                   .resolveDirectoryUrl(this.file.cacheDirectory)\r\n                   .then((dir:DirectoryEntry) => {\r\n                       this.onResolveDirectoryUrlSuccess(dir, filename, data, this.fileWriter, {\r\n                           create: true,\r\n                           exclusive: false\r\n                       })\r\n                   })\r\n                   .catch((error:any) => {\r\n                       console.log(\"FileHelper.save error\", dir, filename, error);\r\n                   });\r\n    }\r\n\r\n    private onResolveDirectoryUrlSuccess(dir:DirectoryEntry,\r\n                                         filename:string,\r\n                                         data:LanguageDataResponseVO,\r\n                                         file_action:(args:Array<any>) => void,\r\n                                         flags:any):void {\r\n        console.log(\"FileHelper.onResolveDirectoryUrlSuccess\", dir, filename);\r\n        this.gotFileSystem(dir, filename, file_action, flags, data);\r\n    }\r\n\r\n    private gotFileSystem(dir:DirectoryEntry,\r\n                          filename:string,\r\n                          action:Function,\r\n                          flags:{ create:boolean, exclusive?:boolean },\r\n                          json?:LanguageDataResponseVO):void {\r\n\r\n        console.log('FileHelper.gotFileSystem - nome file: ' + filename);\r\n\r\n        dir.getFile(filename, flags,\r\n            (fileEntry) => {\r\n                console.log(\"FileHelper.gotFileSystem getFile succes\", dir, filename, fileEntry);\r\n                action.call(this, [fileEntry, json]);\r\n            },\r\n            (error) => {\r\n                console.log(\"FileHelper.gotFileSystem getFile error\", dir, filename, error);\r\n            }\r\n        );\r\n    }\r\n\r\n    private fileWriter(args:Array<any>) {\r\n\r\n        console.log('App.LanguageService.fileWriter');\r\n\r\n        let fileEntry:FileEntry = args[0];\r\n        let json:string = args[1];\r\n\r\n        let blob = new Blob([\"text to save\"], {type: 'text/plain'});\r\n\r\n        fileEntry.createWriter(\r\n            (file:any) => {\r\n                console.log('App.LanguageService.SUCCESS', blob);\r\n\r\n                file.onwritestart = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onwritestart - success file_name', fileEntry.name, event);\r\n                };\r\n                /**\r\n                 * Handler for progress events.\r\n                 */\r\n                file.onprogress = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onprogress - success file_name', fileEntry.name, event);\r\n                };\r\n                /**\r\n                 * Handler for write events.\r\n                 */\r\n                file.onwrite = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onwrite - success file_name', fileEntry.name, event);\r\n                };\r\n                /**\r\n                 * Handler for abort events.\r\n                 */\r\n                file.onabort = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onabort - success file_name', fileEntry.name, event);\r\n                };\r\n                /**\r\n                 * Handler for error events.\r\n                 */\r\n                file.onerror = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onerror - success file_name', fileEntry.name, event);\r\n                };\r\n                /**\r\n                 * Handler for write end events.\r\n                 */\r\n                file.onwriteend = (event: ProgressEvent) => {\r\n                    console.log('FileHelper.fileWriter onwriteend - success file_name', fileEntry.name, event);\r\n                };\r\n\r\n                file.write(blob);\r\n            },\r\n            (error) => {\r\n                console.log('App.LanguageService.FAIL', error);            }\r\n        );\r\n    }\r\n\r\n}\r\n```\r\n\r\nThis is android behaviour, under iOS everything works correctly"}}
{"actor":{"display_login":"lucabro81"}}