Last active
February 8, 2016 13:07
-
-
Save raulanatol/bd4a57b14b8a7eaebfdc to your computer and use it in GitHub Desktop.
Uploading to S3 (bash script)
This file contains 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
#!/usr/bin/env bash | |
bucket=your-bucket | |
resource="/${bucket}/${file}" | |
file=/file_to_upload | |
contentType="application/x-compressed-tar" | |
dateValue=`date -R` | |
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}" | |
s3Key=xxxxxxxxxxxxxxxxxxxx | |
s3Secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64` | |
curl -X PUT -T "${file}" \ | |
-H "Host: ${bucket}.s3.amazonaws.com" \ | |
-H "Date: ${dateValue}" \ | |
-H "Content-Type: ${contentType}" \ | |
-H "Authorization: AWS ${s3Key}:${signature}" \ | |
https://${bucket}.s3.amazonaws.com/${file} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment