Skip to content

Instantly share code, notes, and snippets.

@tariqhamid
Forked from polvi/3G-camera.gs
Created August 9, 2016 19:00
Show Gist options
  • Save tariqhamid/9e333f0230ef53e65ee4f0875f69fff4 to your computer and use it in GitHub Desktop.
Save tariqhamid/9e333f0230ef53e65ee4f0875f69fff4 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