bootstrap-s3.py 文件源码

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

项目:videofront 作者: openfun 项目源码 文件源码
def create_bucket(self, bucket_name, acl):
        backend = Backend()
        try:
            backend.s3_client.head_bucket(Bucket=bucket_name)
            self.stdout.write("Bucket {} already exists".format(bucket_name))
        except ClientError:
            self.stdout.write("Creating bucket {}...".format(bucket_name))
            backend.s3_client.create_bucket(
                ACL=acl,
                Bucket=bucket_name,
                CreateBucketConfiguration={
                    'LocationConstraint': settings.AWS_REGION
                }
            )
            self.stdout.write("Updating CORS configuration...")
            backend.s3_client.put_bucket_cors(
                Bucket=bucket_name,
                CORSConfiguration={
                    'CORSRules': [
                        {
                            'AllowedHeaders': [
                                '*',
                            ],
                            'AllowedMethods': [
                                'GET', 'PUT',
                            ],
                            'AllowedOrigins': [
                                '*',
                            ],
                            'MaxAgeSeconds': 3000
                        },
                    ]
                }
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号