Last active
May 31, 2019 18:30
-
-
Save lsferreira42/c2b6240b66f9464e20abc30fcdc87d79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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