Created
June 30, 2016 14:23
-
-
Save ChrisFlannagan/29c874504e983c71d156d31d4f19fdf6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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