Skip to content

Instantly share code, notes, and snippets.

@lsferreira42
Last active May 31, 2019 18:30
Show Gist options
  • Save lsferreira42/c2b6240b66f9464e20abc30fcdc87d79 to your computer and use it in GitHub Desktop.
Save lsferreira42/c2b6240b66f9464e20abc30fcdc87d79 to your computer and use it in GitHub Desktop.
import boto3
import sys
import os
session = boto3.session.Session(profile_name='legado')
s3 = session.client('s3')
def upload_to_s3(path, bucket):
for root,dirs,files in os.walk(path):
for file in files:
print(os.path.join(root,file))
s3.upload_file(os.path.join(root,file),bucket,os.path.join(root,file))
def main():
bucket = sys.argv[1]
folder = sys.argv[2]
print(bucket, folder)
print("Uploading {}".format(folder))
try:
upload_to_s3(folder, bucket)
except Exception as err:
print(err)
return
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment