Download file from AWS S3 using Python

前端 未结 3 963
梦如初夏
梦如初夏 2020-12-24 02:12

I am trying to download a file from Amazon S3 bucket to my local using the below code but I get an error saying \"Unable to locate credentials\"

Given below is the c

3条回答
  •  误落风尘
    2020-12-24 02:55

    You are not using the session you created to download the file, you're using s3 client you created. If you want to use the client you need to specify credentials.

    your_bucket.download_file('k.png', '/Users/username/Desktop/k.png')
    

    or

    s3 = boto3.client('s3', aws_access_key_id=... , aws_secret_access_key=...)
    s3.download_file('your_bucket','k.png','/Users/username/Desktop/k.png')
    

提交回复
热议问题