zampa
zampa

Reputation: 93

FileNotFoundError: [Errno 2] No such file or directory boto3 aws

I am using boto3 to download a file and then copy in tmp file on lambda funtions . I am using this function to download a file

S3_BUCKET_NAME = 'dev-bucket'
key = 'uploads/random.xlsx'
s3.download_file(S3_BUCKET_NAME, key, 'tmp/hello2.xlsx')

but I am getting this error

FileNotFoundError: [Errno 2] No such file or directory: 'tmp/hello2.xlsx.a56DfB10'

am I doing something wrong here ?

Upvotes: 1

Views: 4518

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269091

Change tmp/hello2.xlsx into: /tmp/hello2.xlsx

Without the leading slash, it will go to a relative path.

By including the leading slash, it will go to an absolute path, which is what you need.

Upvotes: 1

Related Questions