Created
February 20, 2015 22:09
-
-
Save justinlund/e82f929d0a187e1983c7 to your computer and use it in GitHub Desktop.
Quick script to demonstrate authenticating a request to download a private object from DreamObjects
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 | |
# Basic shell script to download a private object | |
# from DreamHost DreamObjects | |
file=$1 | |
bucket="My_Bucket" | |
resource="/${bucket}/${file}" | |
dateValue=`date -Ru` | |
stringToSign="GET\n\n\n${dateValue}\n${resource}" | |
echo ${stringToSign} | |
s3Key="My_Access_Key" | |
s3Secret="My_Secret_Key" | |
echo "Retrieving From DreamObjects" | |
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64` | |
curl -vv -X GET \ | |
-H "Host: ${bucket}.objects.dreamhost.com" \ | |
-H "Date: ${dateValue}" \ | |
-H "Authorization: AWS ${s3Key}:${signature}" \ | |
${bucket}.objects.dreamhost.com/${file} -o ${file} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment