微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尽管 Google 支持确认已启用计费,但将文件上传到 GCS 存储桶时会出现未启用计费的错误

如何解决尽管 Google 支持确认已启用计费,但将文件上传到 GCS 存储桶时会出现未启用计费的错误

我正在尝试使用程序中的 python google cloud storage api 通过 GCS 将图像文件上传到存储桶之一。我可以通过程序列出存储桶,但是在上传图像时,出现以下错误。 :

google.api_core.exceptions.Forbidden: 403 POST https://storage.googleapis.com/upload/storage/v1/b/projbucket1/o?uploadType=multipart: {
"error": {
"code": 403,"message": "The account for bucket \"projbucket1\" has not enabled billing.","errors": [
{
"message": "The account for bucket \"projbucket1\" has not enabled billing.","domain": "global","reason": "accountdisabled","locationType": "header","location": "Authorization"
}
]
}
}
: ('Request Failed with status code',403,'Expected one of',<HTTPStatus.OK: 200>)

其中 projbucket1 是我要上传文件的存储桶。

我为此使用了以下 python 代码


    def upload_image(Imagedata,kind):
        image_filename = Imagedata.filename
        fullpath = os.path.join(app.root_path,'static/images',image_filename)
        bucket_name = "projbucket1"
        if kind == "User" :
            destination = "projbucket1/UserImages/"+image_filename
        else:
            destination = "projbucket1/Postimages/"+image_filename
    
        storage_client = storage.Client()
        buckets = storage_client.list_buckets()
        for bucket in buckets:
            print(bucket.name)
        bucket = storage_client.get_bucket(bucket_name)
        blob = bucket.blob(destination)
        blob.upload_from_filename(fullpath)

我对我正在使用的服务帐户具有存储管理员和所有者权限。在这种情况下,请帮助我。

谢谢, 调息

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。