Skip to content

Instantly share code, notes, and snippets.

@thinkjrs
Created April 10, 2022 01:33
Show Gist options
  • Select an option

  • Save thinkjrs/f76b1279df2dce7e68cd65ecc99bfa72 to your computer and use it in GitHub Desktop.

Select an option

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
#! /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