Skip to content

Instantly share code, notes, and snippets.

@jsbonso
Created December 20, 2022 03:00
Show Gist options
  • Save jsbonso/30d8e177ce5c438e938aec3e1bf63595 to your computer and use it in GitHub Desktop.
Save jsbonso/30d8e177ce5c438e938aec3e1bf63595 to your computer and use it in GitHub Desktop.
Upload new file to Amazon S3 via AWS CLI
# Get the latest file that's added in the folder
LATEST_FILE=`ls -tp | grep -v /$ | head -1`
echo $LATEST_FILE
# Upload the new file to your Amazon S3 Bucket.
# In this example, the "jonbonso-media" S3 bucket has an associated CloudFront distribution
# with a custom domain of "media.jonbonso.com"
aws s3 cp $LATEST_FILE s3://jonbonso-media
# Only applicable for Mac Users
# Copy the CDN URL to your clipboard
echo https://media.jonbonso.com/$LATEST_FILE | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment