尽管 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 (将#修改为@)