Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created July 10, 2013 23:17
Show Gist options
  • Save cfjedimaster/5971113 to your computer and use it in GitHub Desktop.
Save cfjedimaster/5971113 to your computer and use it in GitHub Desktop.
function gotPic(data) {
window.resolveLocalFileSystemURI(data, function(entry) {
var reader = new FileReader();
reader.onloadend = function(evt) {
var byteArray = new Uint8Array(evt.target.result);
var output = new Array( byteArray.length );
var i = 0;
var n = output.length;
while( i < n ) {
output[i] = byteArray[i];
i++;
}
var parseFile = new Parse.File("mypic.jpg", output);
parseFile.save().then(function(ob) {
navigator.notification.alert("Got it!", null);
console.log(JSON.stringify(ob));
}, function(error) {
console.log("Error");
console.log(error);
});
}
reader.onerror = function(evt) {
console.log('read error');
console.log(JSON.stringify(evt));
}
entry.file(function(s) {
reader.readAsArrayBuffer(s);
}, function(e) {
console.log('ee');
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment