Skip to content

Instantly share code, notes, and snippets.

@dceddia
Created June 15, 2018 02:03
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 dceddia/ed779298238cf6b9e9db432458314f64 to your computer and use it in GitHub Desktop.
Save dceddia/ed779298238cf6b9e9db432458314f64 to your computer and use it in GitHub Desktop.
Upload each picture as it is taken
// Here's the timer code, lifted from takePicture:
queuePhoto = () => {
// In 27 seconds, turn the camera back on
setTimeout(() => {
this.setState({ photo: null });
}, PHOTO_INTERVAL - FOCUS_TIME);
// In 30 seconds, take the next picture
setTimeout(this.takePicture, PHOTO_INTERVAL);
}
// Take the picture, upload it, and
// then queue up the next one
takePicture = () => {
this.camera.takePictureAsync({
quality: 0.1,
base64: true,
exif: false
}).then(photo => {
this.setState({ photo }, () => {
this.uploadPicture()
.then(this.queuePhoto)
.catch(this.queuePhoto);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment