Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use S3 as a url short-linker / redirection service
#!/bin/bash -x
if [[ $# -eq 0 ]] ; then
echo 'Usage: cmd <s3 path> <redirect-location>'
echo 'e.g.'
echo 'redirect-url-s3.sh www.fullstackreact.com/r/react-from-zero-satisfaction https://nate177.typeform.com/to/PTJ9ZI'
exit 0
fi
S3_PATH=$1
REDIRECT_URL=$2
cd ~/Desktop
rm index.html || :
touch index.html
s3cmd put --acl-public index.html s3://${S3_PATH}/index.html
s3cmd modify --add-header=x-amz-website-redirect-location:${REDIRECT_URL} s3://${S3_PATH}/index.html
s3cmd modify --add-header='Content-Type: text/html' s3://${S3_PATH}/index.html
open ${S3_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.