-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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