Forked from drfill/gist:c18308b6d71ee8032efda870b9be348e
Created
October 15, 2020 00:06
-
-
Save hatembentayeb/774f6aca2eb58fca28280f3ddc27b3ec to your computer and use it in GitHub Desktop.
Amazon S3 download with Curl
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/sh | |
file=path/to/file | |
bucket=your-bucket | |
resource="/${bucket}/${file}" | |
contentType="application/x-compressed-tar" | |
dateValue="`date +'%a, %d %b %Y %H:%M:%S %z'`" | |
stringToSign="GET | |
${contentType} | |
${dateValue} | |
${resource}" | |
s3Key=xxxxxxxxxxxxxxxxxxxx | |
s3Secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
signature=`/bin/echo -en "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64` | |
curl -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