Johnny
09/23/2020, 5:04 PMChris White
09/23/2020, 5:08 PMJohnny
09/23/2020, 5:10 PMS3ResultHandler(bucket='<some bucket name>', aws_credentials_secret="aws_credentials")
atm i was attempting to use this ^
the aws_credentials is a secret dictionary setup in cloudChris White
09/23/2020, 5:11 PMJohnny
09/23/2020, 5:11 PM@task
def s3_to_string():
""" function to read from s3 and return string from txt file """
resource = boto3.resource('s3')
my_bucket = resource.Bucket('some-bucket')
file1 = 'some-file.txt'
files = list(my_bucket.objects.filter(Prefix=file1))
if files:
obj = files[0].get()
body = obj['Body']
string = body.read().decode("utf-8")
return string
else:
print('no file found')
Chris White
09/23/2020, 5:15 PMJohnny
09/23/2020, 5:16 PMChris White
09/23/2020, 5:17 PMJohnny
09/23/2020, 7:33 PMChris White
09/23/2020, 7:39 PMMarvin
09/23/2020, 7:39 PM