Upload files to S3 Bucket using curl.
I followed the information below.
tuxfight3r/s3_upload.sh
#!/bin/bash
S3KEY="Your Acess Key"
S3SECRET="Your Access Secret"
S3BUCKET="Your Bucket Name"
S3STORAGETYPE="STANDARD"
AWSREGION="Your S3 Region"
# If you use mac OS. enable following code.
#OS="mac"
function putS3
{
file_path=$1
aws_path=$2
bucket="${S3BUCKET}"
date=$(date -R -u)
acl="x-amz-acl:private"
content_type="text/plain"
storage_type="x-amz-storage-class:${S3STORAGETYPE}"
string="PUTnn$content_typen$daten$acln$storage_typen/$bucket$aws_path${file_path##/*/}"
if [ $OS = "mac" ]; then
signature=$(printf "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
else
signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64)
fi
curl -s --retry 3 --retry-delay 10 -X PUT -T "$file_path"
-H "Host: $bucket.${AWSREGION}.amazonaws.com"
-H "Date: $date"
-H "Content-Type: $content_type"
-H "$storage_type"
-H "$acl"
-H "Authorization: AWS ${S3KEY}:$signature"
"https://$bucket.${AWSREGION}.amazonaws.com$aws_path${file_path##/*/}"
}
# Upload test.txt file to /test/ folder.
putS3 test.txt /test/











