We take a photo using PhoneGap camera plugin and save photo in localstorage. The key is to base64 it at this point.
navigator.camera.getPicture(function (imageData) {
assembleDate();
document.getElementById('dormPhoto').src = "data:image/jpeg;base64," + imageData;
localStorage.dormPhoto = "data:image/jpeg;base64," + imageData;
$('#dormPhoto').css({
height: "auto",
width: "auto"
});
}, function (message) {
// alert(message);
}, {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
targetWidth: 320,
targetHeight: 240,
saveToPhotoAlbum: true
});
You can then use the localstorage content for the body: of the CreateFile api
window.df.apis.files.createFile({
"container": "dormfinder",
"file_path": filename,
"body": localStorage.dormPhoto
},
function (response) {
if (App.testing_on_desktop) {
alert("Your Dorm Successfully Submitted.");
} else {
navigator.notification.alert('Your Dorm Successfully Submitted.', function () {}, 'Success', 'Continue');
}
$('#addMapPage').removeClass('ui-disabled');
goTo("#homePage");
hideLoader();
},
function (response) {
$('#addMapPage').removeClass('ui-disabled');
alert(window.app.getErrorString(response));
hideLoader();
}
);
I hope this is helpful.