Skip to content

Instantly share code, notes, and snippets.

@tomasmuller
Created November 14, 2016 12:06
Show Gist options
  • Save tomasmuller/1b5719a66ccd78a4570dd393b965ceee to your computer and use it in GitHub Desktop.
Save tomasmuller/1b5719a66ccd78a4570dd393b965ceee to your computer and use it in GitHub Desktop.
#!/bin/bash
file="$1"
key_id="***AWS_ACCESS_KEY_ID***"
key_secret="***AWS_SECRET_ACCESS_KEY***"
path="your/path/$file"
bucket="your-bucket"
content_type="application/octet-stream"
date="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
md5="$(openssl md5 -binary < "$file" | base64)"
sig="$(printf "PUT\n$md5\n$content_type\n$date\n/$bucket/$path" | openssl sha1 -binary -hmac "$key_secret" | base64)"
curl -v -i -X PUT -T $file http://$bucket.s3.amazonaws.com/$path \
-H "Date: $date" \
-H "Authorization: AWS $key_id:$sig" \
-H "Content-Type: $content_type" \
-H "Content-MD5: $md5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment