#import statements import boto3 import sys #boto3 client definition s3 = boto3.client('s3') #create sentinel loop userIn = '' print('Welcome to Bucket Accessor. Please enter the letter associated with what you want to do.') while userIn != 'g': print(' Enter a to create a buckets \n Enter b to put object in bucket \n Enter c to delete object in bucket \n Enter d to delete a bucket \n Enter e to copy between buckets \n Enter f to download from bucket \n Enter g to exit') userIn = input("Enter input: ") #create bucket if userIn == 'a': userIn1 = input('Enter name of bucket: ') bucket_name = userIn1 s3.create_bucket(Bucket=bucket_name) #put object in bucket elif userIn == 'b': userIn1 = str(input('Enter name of bucket: ')) userIn2 = str(input('Enter name of file: ')) response = s3.upload_file(Filename=userIn2,Bucket=userIn1,Key = userIn2) #delete object in bucket elif userIn == 'c': userIn1 = str(input('Enter name of bucket: ')) userIn2 = str(input('Enter name of file: ')) s3.delete_object(Bucket = userIn1, Key = userIn2) #delete bucket elif userIn == 'd': userIn1 = input('Enter name of bucket to delete: ') s3 = boto3.resource('s3') bucket = s3.Bucket(userIn1) bucket.delete() #copy from bucket to bucket elif userIn == 'e': userIn1 = str(input('Enter name of bucket to copy from: ')) userIn2 = str(input('Enter name of file: ')) userIn5 = str(input('Enter name of next bucket: ')) s3 = boto3.resource('s3') copy_source = { 'Bucket': userIn1, 'Key': userIn2 } s3.meta.client.copy(copy_source, userIn5, Key = userIn2) #download from file elif userIn == 'f': userIn1 = str(input('Enter name of bucket: ')) userIn2 = str(input('Enter name of file: ')) userIn3 = input('Enter a new name of file: ') s3.download_file(userIn1 , userIn2, userIn3) #exit program enter g