Home > Software design >  FileNotFoundError: [Errno 2] No such file or directory boto3 aws
FileNotFoundError: [Errno 2] No such file or directory boto3 aws

Time:02-24

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 ?

CodePudding user response:

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.

  • Related