I would like to update an image taken from my phone to Parse, we are struggling with this simple feature since we cannot convert our ImageUri to a real file with Phonegap (in order to upload it to our Parse server), We are using Ripple to emulate the phone behaviour.
We have try with this piece of code:
var reader = new FileReader();
reader.onloadend = function(evt) {
console.log("read success");
console.log(evt.target.result);
evt.target.result;
};
reader.readAsText(user.myPicture);
But i get this error: TypeError: Object #<Console> has no method 'warning'
Seems like FileReader of phonegap does not like the kind of URI that I get from navigator.camera.getPicture()
$scope.getPicture = function(){
navigator.camera.getPicture(onSuccess, onFail,
//Options => http://docs.phonegap.com/en/2.6.0/cordova_camera_camera.md.html#Camera
{ quality: 50,
destinationType:Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY ,//CAMERA,
targetWidth: 100,
targetHeight: 100
});
function onSuccess(imageURI) {
var image = document.getElementById('preview');
image.src = imageURI;
$scope.myPicture = image.src;
// $scope.$apply(function() {
// ctrl.$setViewValue(image.src);
// });
}
function onFail(message) {
alert('Failed because: ' + message);
ctrl.$setValidity('Failed because: ' + message, false);
}
};
Is there any other way in to get the File without using JQuery $.get()?
There is a similar post here that has the same problem