Last active
August 9, 2016 19:00
-
-
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
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
/* 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