Uploading and downloading documents from Amazon S3 using bash

You need to upload a file to S3 and cannot install new packages in the server, nor the s3 client tools. You only have bash, openssl and sed. Go.

I found and adapted a script by Viktor Szakats, that creates all the proper headers expected by the latest AWS API. I had lots of trouble with whitespaces and empty lines. Be mindful of that when modifying these scripts:

s3-upload-aws4.sh

s3-download-aws4.sh

run them like:

. s3-upload-aws4.sh "myfile.ext" "my_bucket_name" "folder_name_in_bucket" "region" "REDUCED_REDUNDANCY" "MY_AWS_ACCESS_KEY" "MY_AWS_SECRET_KEY"

 

Published
Categorized as Software

By Daniel Pradilla

I'm an Engineer and my main objective is to help people solve real world problems using readily available technologies. I've been doing it since I was a kid.

Discover more from Daniel Pradilla

Subscribe now to keep reading and get access to the full archive.

Continue reading