Created
March 20, 2014 10:59
-
-
Save ds0nt/9661376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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