Skip to content

Instantly share code, notes, and snippets.

@polvi
Last active August 9, 2016 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save polvi/a16bec55fef0dd1e06a0 to your computer and use it in GitHub Desktop.
Save polvi/a16bec55fef0dd1e06a0 to your computer and use it in GitHub Desktop.
app-script for taking a twilio MMS post from a 3G game camera to google drive
/* Connect your 3g game camera to google drive
* 1) buy camera: http://www.amazon.com/Covert-Special-Ops-Cellular-Camera/dp/B00806KGY6
* 2) Configure it to point to your twilio number
* 3) Deploy google app script below as a public webapp
* 4) Configure twilio to point to your app script
*/
function doGet() {
return ContentService.createTextOutput("");
}
function doPost(e) {
var drop = "camp camera";
var folder, folders = DriveApp.getFoldersByName(drop);
/* Find the folder, create if the folder does not exist */
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(drop);
}
/* Twilio sends the URL, download it */
/* https://www.twilio.com/docs/api/twiml/sms/twilio_request */
var blob = UrlFetchApp.fetch(e.parameters.MediaUrl0).getAs("image/jpeg");
var file = folder.createFile(blob);
return ContentService.createTextOutput("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment