Skip to content

Instantly share code, notes, and snippets.

@ChrisFlannagan
Created June 30, 2016 14:23
Show Gist options
  • Save ChrisFlannagan/29c874504e983c71d156d31d4f19fdf6 to your computer and use it in GitHub Desktop.
Save ChrisFlannagan/29c874504e983c71d156d31d4f19fdf6 to your computer and use it in GitHub Desktop.
exports.takephoto = function(args) {
cameraModule.takePicture().then(function(picture) {
var savepath = fsModule.knownFolders.documents().path;
var filename = 'img_' + new Date().getTime() + '.' + enumsModule.ImageFormat.jpeg;
var filepath = fsModule.path.join(savepath, filename);
console.log("Save: + " + picture);
if(picture.saveToFile(filepath, format)) {
var session = bghttp.session("image-upload");
console.logi("Saving");
var request = {
url: config.apiUrl,
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name": filename
},
description: "{ 'uploading': '" + filename + "' }"
};
var task = session.uploadFile("file://" + filepath, request);
task.on("progress", logEvent);
task.on("error", logEvent);
task.on("complete", logEvent);
function logEvent(e) {
console.log(e.eventName);
}
} else {
console.log("Failed To Save");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment