-
-
Save vadikgo/7b82b26b749eade48fa25c7acda7d6e6 to your computer and use it in GitHub Desktop.
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
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
S3KEY="YOUR-ACCESSKEY" | |
S3SECRET="YOUR-SECRETKEY" | |
function putS3 | |
{ | |
path=$1 | |
file=$2 | |
aws_path=$3 | |
bucket='my-bucket' | |
date=$(date +"%a, %d %b %Y %T %z") | |
content_type='application/octet-stream' | |
string="PUT\n\n$content_type\n$date\n\n/$bucket$aws_path$file" | |
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) | |
curl -X PUT -T "$path/$file" \ | |
-H "Host: play.minio.io:9000" \ | |
-H "Date: $date" \ | |
-H "Content-Type: $content_type" \ | |
-H "Authorization: AWS ${S3KEY}:$signature" \ | |
"https://play.minio.io:9000/$bucket/$aws_path$file" | |
} | |
for file in "$path"/*; do | |
putS3 "$path" "${file##*/}" "/path/on/s3/to/files/" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment