Skip to content

Instantly share code, notes, and snippets.

@vintesh
Forked from cfjedimaster/gist:5971113
Last active December 22, 2016 07:04
Show Gist options
  • Save vintesh/a8eb1d8e85002ebdc3fe to your computer and use it in GitHub Desktop.
Save vintesh/a8eb1d8e85002ebdc3fe to your computer and use it in GitHub Desktop.
Parse.com - Cordova - Camera Plugin - Read File - Save to server in PNG/JPG format.
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