Amazon Web Services (AWS) provides flexible cloud hosting and storage. With Addigy, it can be easy to upload files from your devices to your AWS storage.


The scripts in this article can be implemented with limited modification through Addigy's Predefined Commands. If you aren't familiar with running scripts from Predefined Commands, check out our article Creating and Running Scripts.   


Also, if you use Slack, we recommend using the simpler methods for file uploads described in our article Uploading Files from a Device to Slack.


Of course, with this method, you will need to have an AWS bucket that your device can reach. This upload method uses a curl command that has some files and authentication wrapped in the headers to authenticate and denote the file.


Simply change the variables in the first six lines to get this script working.


aws_key="your aws key"
aws_secret="your aws secret" 
path="FILE DIRECTORY"
file="FILE BASENAME"
aws_path="ENTER AWS PATH HERE"
bucket="YOUR BUCKET NAME"


date=$(date +"%a, %d %b %Y %T %z")
acl="x-amz-acl:public-read"
content_type='application/x-compressed-tar'
string="PUT\n\n$content_type\n$date\n$acl\n/$bucket$aws_path$file"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${aws_secret}" -binary | base64)


# This is the curl command that does all the work.
curl -X PUT -T "$path/$file" \
    -H "Host: $bucket.s3.amazonaws.com" \
    -H "Date: $date" \
    -H "Content-Type: $content_type" \
    -H "$acl" \
    -H "Authorization: AWS ${aws_key}:$signature" \
    "https://$bucket.s3.amazonaws.com$aws_path$file"


This may look fancy, but you can accomplish the same results with many other types of file servers. All you need is the ability to PUT files into them and some basic authentication.