Here is a method that will take care of the nested directory structure and be able to download the full directory using boto
def upload_directory(): for root, dirs, files in os.walk(settings.LOCAL_SYNC_LOCATION): nested_dir = root.replace(settings.LOCAL_SYNC_LOCATION, '') if nested_dir: nested_dir = nested_dir.replace('/','',1) + '/' for file in files: complete_file_path = os.path.join(root, file) file = nested_dir + file if nested_dir else file print "[S3_UPLOAD] Going to upload {complete_file_path} to s3 bucket {s3_bucket} as {file}"\ .format(complete_file_path=complete_file_path, s3_bucket=settings.S3_BUCKET, file=file) s3_client.upload_file(complete_file_path, settings.S3_BUCKET, file)
source share