Skip to content

Instantly share code, notes, and snippets.

@hiroshi
Created June 23, 2015 00:38
Show Gist options
  • Save hiroshi/d20e7a6b0314f9ef1263 to your computer and use it in GitHub Desktop.
Save hiroshi/d20e7a6b0314f9ef1263 to your computer and use it in GitHub Desktop.
# http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
# file=xxxx
# bucket=xxxx
# s3Key=xxxx
# s3Secret=xxxx
resource=/${bucket}/${file}
contentType=binary/octet-stream
dateValue := $(shell date "+%a, %d %b %Y %H:%M:%S %z")
SHELL=bash # Enable echo -ne option
signature:=$(shell echo -ne "PUT\n\n${contentType}\n${dateValue}\n${resource}" | openssl sha1 -hmac ${s3Secret} -binary | base64)
upload-update:
curl -k -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