I have an excel file in generated from a Lamba function, stored in the /tmp/ folder, I want to store it in a S3 bucket, I have setup the permisions and the bucket, but when I complete the function it creates an damaged excel file in the bucket, which cannot be opened.
The code I used:
import boto3
def uploadtoS3(filename=str):
s3 = boto3.client('s3')
bucket = 'aws-day-ahead-estimations'
DirName = '/tmp/' + filename
s3.put_object(Bucket=bucket,Body=DirName,Key=filename)
print('put complete')