Created
June 15, 2018 02:03
-
-
Save dceddia/ed779298238cf6b9e9db432458314f64 to your computer and use it in GitHub Desktop.
Upload each picture as it is taken
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
// 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