Tuesday, 15 January 2013

javascript - How to write blob data to image file in Phonegap? -



javascript - How to write blob data to image file in Phonegap? -

i trying utilize phonegap filewriter api write blob info image file. here code using create blob first:

function datauritoblob(datauri) { var binary = atob(datauri.split(',')[1]); var array = []; for(var = 0; < binary.length; i++) { array.push(binary.charcodeat(i)); } homecoming new blob([new uint8array(array)], {type: 'image/jpeg'}); }

i looked through of documentation on filewriter api , not understand much. here tried far:

function saveblobtofile(blob) { // root file scheme entry var root = getfilesystemroot(); // writes file write_file = function(writer) { // write file writer.write(blob); }; // creates filewriter object create_writer = function(fileentry) { fileentry.createwriter(write_file, null); }; var newid = makeid(); // create file , write root.getfile(newid + '.png', {create: true}, create_writer, null); }

that bit not sure going on. when seek run on ipad nil happens. want save blob info randomly-generated filename ".png" extension. how can properly, , file saved afterwards?

javascript cordova filewriter

No comments:

Post a Comment