Uploading file(s) to Amazon S3 using python + boto & s3afe.py script

Tools Used: python, boto, s3afe.py

Step 1: Be sure to have python first and then make sure you can Install boto module in python as well

  • $sudo easy_install pip
  • $ sudo pip install boto


Step 2: Download s3afe.py from the link below:


Step 3: Setup execution mode (chmod) to s3afe.py and verify that it executes on your machine:

AvkashMBP2:~ userx$ /usr/local/bin/s3afe.py
Usage: s3afe.py -k [access key id] -s [secret access key] -b [bucketname] -n [keyname] -f [file]

S3afe stores a file on Amazon S3

–version show program’s version number and exit
-h, –help show this help message and exit
-k AWSKEY, –aws_access_key_id=AWSKEY
-s AWSSECRET, –aws_secret_access_key=AWSSECRET
-n KEYNAME, –keyname=KEYNAME
-a ACL, –acl=ACL


Step 4: To upload a file from your local machine to Amazon S3 you will use the following parameters:

  -k AWSKEY, --aws_access_key_id=AWSKEY
  -s AWSSECRET, --aws_secret_access_key=AWSSECRET
  -f FILENAME, --filename=FILENAME  <-- Source File Name
  -b BUCKETNAME, --bucketname=BUCKETNAME
  -n KEYNAME, --keyname=KEYNAME  <-- New File Name after the upload
  -a ACL, --acl=ACL <-- Use 'private' here


Real Usage Example (From my mac):

$/usr/local/bin/s3afe.py  -f ‘/Users/userx/Downloads/file1.tgz’ -n ‘file.tgz’ -b ‘AMAZON_BUCKET_NAME’ -a ‘private’ -k ‘AMAZON_S3_ACCESS_KEY’ -s ‘AMAZON_S3_SECRET_KEY’ 

Note: After file upload is completed, you may get an error as below which is benign because the file does upload and I am not sure why I get this error.

Error: Please check your Amazon credentials!

S3afe.py Documentation: https://code.google.com/p/s3afe/




One thought on “Uploading file(s) to Amazon S3 using python + boto & s3afe.py script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s