connection.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:antenna 作者: mozilla-services 项目源码 文件源码
def _build_client(self):
        # Either they provided ACCESS_KEY and SECRET_ACCESS_KEY in which case
        # we use those, or they didn't in which case boto3 pulls credentials
        # from one of a myriad of other places.
        # http://boto3.readthedocs.io/en/latest/guide/configuration.html#configuring-credentials
        session_kwargs = {}
        if self.config('access_key') and self.config('secret_access_key'):
            session_kwargs['aws_access_key_id'] = self.config('access_key')
            session_kwargs['aws_secret_access_key'] = self.config('secret_access_key')
        session = boto3.session.Session(**session_kwargs)

        kwargs = {
            'service_name': 's3',
            'region_name': self.config('region'),
            # NOTE(willkg): We use path-style because that lets us have dots in
            # our bucket names and use SSL.
            'config': Config(s3={'addressing_style': 'path'})
        }
        if self.config('endpoint_url'):
            kwargs['endpoint_url'] = self.config('endpoint_url')

        return session.client(**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号