Skip to content

Instantly share code, notes, and snippets.

@ds0nt
Created March 20, 2014 10:59
Show Gist options
  • Save ds0nt/9661376 to your computer and use it in GitHub Desktop.
Save ds0nt/9661376 to your computer and use it in GitHub Desktop.
var camoptions = {
limit: 1,
destinationType: Camera.DestinationType.FILE_URI,
targetWidth: 512,
targetHeight: 512,
sourceType: (source == 1) ? Camera.PictureSourceType.CAMERA : Camera.PictureSourceType.PHOTOLIBRARY
};
navigator.camera.getPicture(function onSuccess(file) {
api.upload_head_pic(file, function onSuccess(result) {
var data = JSON.parse(result.response);
if (!data.success) {
app.alertError('Could not upload your photo.');
return;
}
p.profile_view.imageholder.change(data.portrait_url);
sidemenu.updatePhoto(data.portrait_url);
app.data.user.portrait_url = data.portrait_url;
navigator.camera.cleanup();
}, function onError(error) {
app.alertError('Could not upload your photo.');
console.log(error);
navigator.camera.cleanup();
});
}, function onError(error) {
app.alertError('Could not access that file.');
console.error(error);
}, camoptions);
FileTransferError
body: null
code: 1
http_status: 200
source: null
target: "http://dan.socialagent.me/v2/apiserver"
__proto__: Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment