Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

Using Boto3, the python script downloads files from an S3 bucket to read them and write the contents of the downloaded files to a file called blank_file.txt.

What my question is, how would it work the same way once the script gets on an AWS Lambda function?

1 Answer

0 votes
by (25.1k points)

In an AWS Lambda function you get a 512 MB of of space in the /tmp folder. This is what you can use to download S3 files or create a new one. And you can use the code mentioned below to do it:

s3client.download_file(bucket_name, obj.key, '/tmp/'+filename) 

... 

my_file = open('/tmp/blank_file.txt', 'w')

In case you are not comfortable with file handling and other python concepts you can take a look at this video:

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...