bucket.py 文件源码

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

项目:django-gstorage 作者: fyndiq 项目源码 文件源码
def get_or_create(cls, bucket_name, client=None):
        """
        If the bucket exists with this name, get it. Else, create it

        :param cls: :class:`gstorage.bucket.Bucket`
        :type bucket_name: string
        :param bucket_name: name of the bucket
        :type client: gcloud.client.Client
        :param client: (optional) instance of client to use
        :return: :class:`Bucket <Bucket>` object
        :raises gcloud.exceptions.BadRequest (400): not a valid bucket name
        :raises gcloud.exceptions.Forbidden (403): The credentials are invalid
        """
        if not client:
            credentials = GoogleCredentials.get_application_default()
            client = Client(credentials=credentials)
        bucket = cls(client, name=bucket_name)
        if not bucket.exists():
            bucket.create()
        return bucket
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号