Skip to content

Instantly share code, notes, and snippets.

@BrunoBernardino
Created December 3, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoBernardino/195c031143f6e4bfb346de413ecc1cd8 to your computer and use it in GitHub Desktop.
Save BrunoBernardino/195c031143f6e4bfb346de413ecc1cd8 to your computer and use it in GitHub Desktop.
AWS Lambda Redirect code
'use strict';
const finish = (cb, url) => {
console.log('Sending to', url);
cb(null, {url: url});
}
exports.handler = (event, context, callback) => {
const defaultURL = 'http://example.com';
const testPath = event.filePath;
console.log('Visiting', testPath);
if (testPath === 'somefile.jpg') {
return finish(callback, 'https://finalexample.com/url/file.jpg');
}
if (testPath === 'someotherfile.jpg') {
return finish(callback, 'https://finalexample.com/url/file2.jpg');
}
// There's about 30 of these...
finish(callback, defaultURL);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment