How to specify credentials when connecting to boto3 S3?

后端 未结 5 2092
我在风中等你
我在风中等你 2020-12-04 08:10

On boto I used to specify my credentials when connecting to S3 in such a way:

import boto
from boto.s3.connection import Key, S3Connection
S3 = S3Connection(         


        
5条回答
  •  死守一世寂寞
    2020-12-04 08:46

    You can get a client with new session directly like below.

     s3_client = boto3.client('s3', 
                          aws_access_key_id=settings.AWS_SERVER_PUBLIC_KEY, 
                          aws_secret_access_key=settings.AWS_SERVER_SECRET_KEY, 
                          region_name=REGION_NAME
                          )
    

提交回复
热议问题