Skip to content

Instantly share code, notes, and snippets.

@techslides
Created May 6, 2015 14:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techslides/ee3aa1ad15c90bd8fb4f to your computer and use it in GitHub Desktop.
Save techslides/ee3aa1ad15c90bd8fb4f to your computer and use it in GitHub Desktop.
App Script as Image Proxy
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);
}
@techslides
Copy link
Author

Learn more about this Google App Script here: http://techslides.com/image-proxy-with-google-app-scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment