extjs - Ext.device.filesystem.FileEntry.read() - type: "text" returns blank file -
i facing problem ext.device.filesystem.fileentry.read() method. when try read text/json file text, blank file. idea? looks readastext method of extjs file reader buggy.
following not work:
var fileentry = new ext.device.filesystem.fileentry(newfilepath, filesystem); fileentry.read({ //type: "binarystring", encoding: 'utf8', type: "text", //type: "text", success: function(filedata) { console.log('--- filedata'); console.log(filedata); console.log('//--- filedata'); self.onuploadjsonsuccess(filedata, filename, networkid, activityid, section, showwaitscreen, callback); }, failure: function(error) { if(showwaitscreen) { console.log('failed read file: ' + error); ext.msg.alert('failed read file: ' + error); } } });
but if change type "text" "binarystring", reads file off course mess special characters.
var fileentry = new ext.device.filesystem.fileentry(newfilepath, filesystem); fileentry.read({ type: "binarystring", success: function(filedata) { console.log('--- filedata'); console.log(filedata); console.log('//--- filedata'); self.onuploadjsonsuccess(filedata, filename, networkid, activityid, section, showwaitscreen, callback); }, failure: function(error) { if(showwaitscreen) { console.log('failed read file: ' + error); ext.msg.alert('failed read file: ' + error); } } });
regards, waheed
changing encoding 'utf-8' trick. so, working code below:
fileentry.read({ //type: "binarystring", type: "text", encoding: "utf-8", success: function(filedata) { console.log('--- filedata'); console.log(filedata); console.log('//--- filedata'); self.onuploadjsonsuccess(filedata, filename, networkid, activityid, section, showwaitscreen, callback); }, failure: function(error) { if(showwaitscreen) { console.log('failed read file: ' + error); ext.msg.alert('failed read file: ' + error); } } });
Comments
Post a Comment