AWS — Отправка файла в S3 Bucket используя cURL

# AWS S3 Credentials
S3_BUCKET="YOUR_S3_BUCKET_NAME"
S3_ACCESS_KEY="YOUR_ACCESS_KEY"
S3_SECRET_KEY="YOUR_SECRET_KEY"

FILE_NAME="test.tar.gz"

# SENDING

date="$(date +%Y%m%d)"
dateFormatted="$(date -R)"
relativePath="/${S3_BUCKET}/${FILE_NAME}"
contentType="application/octet-stream"
stringToSign="PUT\n\n${contentType}\n${dateFormatted}\n${relativePath}"
signature="$(echo -en ${stringToSign} | openssl sha1 -hmac ${S3_SECRET_KEY} -binary | base64)"
curl -X PUT -T "${FILE_NAME}" \
-H "Host: ${S3_BUCKET}.s3.amazonaws.com" \
-H "Date: ${dateFormatted}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${S3_ACCESS_KEY}:${signature}" \
http://${S3_BUCKET}.s3.amazonaws.com/${FILE_NAME}

 

0 0 vote
Article Rating

Метки: Метки

Подписаться
Уведомление о
guest
0 Комментарий
Inline Feedbacks
View all comments