Skip to content

Instantly share code, notes, and snippets.

@felquis
Created June 17, 2014 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felquis/fe8b91489cbf6b8f669d to your computer and use it in GitHub Desktop.
Save felquis/fe8b91489cbf6b8f669d to your computer and use it in GitHub Desktop.
$scope.loadingNewPhoto = false;
$cordovaCamera.getPicture({
sourceType: (index == 1) ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA,
destinationType: (typeof Camera !== "undefined") ? Camera.DestinationType.FILE_URI : false,
targetWidth: 512,
targetHeight: 512
}).then(function(imageData) {
var ft = new FileTransfer();
$scope.loadingNewPhoto = true;
ft.upload(
imageData,
encodeURI(UrlService.baseUrl + "/api/v1/usuarios/me/foto"),
function (result) {
$scope.userInfo.foto = result.data.foto;
$scope.loadingNewPhoto = false;
},
function (err) {
alert('Houve um erro \n' + err);
});
}, function(err) {
console.log('## erro: ', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment