If anyone else works with Phonegap and Parse, here is another useful example from Raymond Camden that takes a picture:
http://www.raymondcamden.com/2013/07/23/better-example-of-phonegap-parse-and-uploading-files
var imagedata = ""; $("#takePicBtn").on("click", function(e) { e.preventDefault(); navigator.camera.getPicture(gotPic, failHandler, {quality:50, destinationType:navigator.camera.DestinationType.DATA_URL, sourceType:navigator.camera.PictureSourceType.PHOTOLIBRARY}); }); function gotPic(data) { console.log('got here'); imagedata = data; $("#takePicBtn").text("Picture Taken!").button("refresh"); }
and it is saved as:
var parseFile = new Parse.File("mypic.jpg", {base64:imagedata}); console.log(parseFile); parseFile.save().then(function() { var note = new NoteOb(); note.set("text",noteText); note.set("picture",parseFile); note.save(null, { success:function(ob) { $.mobile.changePage("#home"); }, error:function(e) { console.log("Oh crap", e); } }); cleanUp(); }, function(error) { console.log("Error"); console.log(error); });
Pay particular attention to {base64:imagedata} , as this is the key to creating a parsing file using string data like this.
source share