Created
May 6, 2015 14:29
-
-
Save techslides/ee3aa1ad15c90bd8fb4f to your computer and use it in GitHub Desktop.
App Script as Image Proxy
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
function doGet(e) { | |
var url = decodeURIComponent(e.parameter.url); | |
try { | |
var response = UrlFetchApp.fetch(url); | |
} catch (e) { | |
return e.toString(); | |
} | |
var type = response.getHeaders()['Content-Type']; | |
var b64 = Utilities.base64Encode(response.getContent()); | |
var data = 'data:'+type+';base64,'+b64; | |
return ContentService.createTextOutput(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn more about this Google App Script here: http://techslides.com/image-proxy-with-google-app-scripts