Created
April 10, 2022 01:33
-
-
Save thinkjrs/f76b1279df2dce7e68cd65ecc99bfa72 to your computer and use it in GitHub Desktop.
Script to upload a local file to an s3 bucket as public returning the https route
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
| #! /usr/bin/sh | |
| # A simple script to upload the file given via the single input parameter | |
| # via the full path to the file. | |
| # This uses Python to grab the filename, since bash and other shell | |
| # scripting languages are comparably unreadable. | |
| bucket_name=<that-sexy-bucket-name-of-yours> | |
| bucket=s3://$bucket_name/ | |
| input=$1 | |
| filename=$(python3 -c "print('$1'.split('/')[-1])") | |
| aws s3 cp $input $bucket --acl public-read > /dev/null | |
| echo "https://$bucket_name.s3.us-east-2.amazonaws.com/$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment