Created
September 27, 2018 17:52
-
-
Save jashmenn/67ce7f5fb0b188f44f04510ae0fe1c01 to your computer and use it in GitHub Desktop.
Use S3 as a url short-linker / redirection service
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
#!/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