Hello. In my application I use box.com api. This api provide posibility to recieve content of file. I want to save this content. If I recieve non-binary file like js, css, txt etc. I save file successfuly. But If I want to save binary file like png or jpg I have a problem.
Content is different. I seem it depenps on encoding. But I can't find solution how I can decedto to right direction.
1) This is my code to save data
var fileName = Tiggr('fileName').text(),
gotFS = function(fileSystem) {
alert('File ' + fileName + ' recieved.');
fileSystem.root.getFile(fileName, {create: true, exclusive: false}, gotFileEntry, fail);
},
gotFileEntry = function(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
},
gotFileWriter = function(writer) {
writer.write(jqXHR.responseText);
},
fail = function(error) {
alert('Error of getting access for FILE SYSTEM. Code ', error.code);
};
console.log('jqXHR = ', jqXHR);
if ((jqXHR) && (jqXHR.responseText)) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
2) I cant use file transfer because I can recieve only content of file, nont file or url of file.