Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hatembentayeb/774f6aca2eb58fca28280f3ddc27b3ec to your computer and use it in GitHub Desktop.
Save hatembentayeb/774f6aca2eb58fca28280f3ddc27b3ec to your computer and use it in GitHub Desktop.

Revisions

  1. @Mindgames Mindgames created this gist Feb 11, 2016.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/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}