Last active
August 2, 2021 03:07
-
-
Save dmitryrck/9640b00ca591ab6841d0838f90f5dc6b to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# I am not the author of this script. | |
# Unfortunately I don't remember where I copied from. | |
file="${1}" | |
bucket="${2}" | |
s3Key="${3}" | |
s3Secret="${4}" | |
resource="/${bucket}/${file}" | |
contentType="application/octet-stream" | |
dateValue="$(date -R)" | |
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}" | |
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