Created
November 14, 2016 12:06
-
-
Save tomasmuller/1b5719a66ccd78a4570dd393b965ceee to your computer and use it in GitHub Desktop.
Revisions
-
tomasmuller created this gist
Nov 14, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ #!/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"