Python AWS Boto3: How to read files from an S3 bucket?

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

My question is: how will it work the same way as soon as the script receives the AWS Lambda function?

+4
source share
2 answers

Lambda provides 512 MB of space . You can use this mount point to store downloaded S3 files or to create new ones. /tmp

s3client.download_file(bucket_name, obj.key, '/tmp/'+filename)
...
blank_file = open('/tmp/blank_file.txt', 'w')

The working directory used by Lambda, /var/taskand this is a read-only file system. You cannot create files in it.

+7

AWS Lambda 500 "/tmp", , .

https://aws.amazon.com/lambda/faqs/

0

Source: https://habr.com/ru/post/1676111/


All Articles