Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Upload static file dir recursively to Amazon S3 using python
from os import listdir
from os.path import isdir
from simples3 import S3Bucket # pip install simples3
root = "../static"
exclude = [".DS_Store"]
A = "access key"
B = "secret key"
bucket = "guidenext"
s3 = S3Bucket(bucket,
base_url="" % bucket)
def upload_file(src):
print "- uploading %s" % src
f = open(src)
s3.put(src.replace(root, "admin"),
def upload_dir(path):
for f in listdir(path):
if f not in exclude:
if isdir("%s/%s" % (path, f)) is True:
upload_dir("%s/%s" % (path, f))
upload_file("%s/%s" % (path, f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.