""" S3 module store common s3 methods ================================= This module lists buckets and uploads a file to an s3 bucket. """ import boto3 def list_buckets(): """This method will list all buckets. Args: none """ s3 = boto3.resource('s3') for bucket in s3.buckets.all(): print(bucket.name) def upload(bucketname, filename, remotefilename): """This method will upload a file to a bucket. Args: bucketname (str): The name of the s3 bucket to upload the file into. filename (str): The name of the local file to be uploaded. remotefilename (str): The name of remote file. """ s3_client = boto3.client('s3') # Upload the file to S3 s3_client.upload_file(filename, bucketname, remotefilename) print('file uploaded: {}'.format(remotefilename))