我想使用包含所有URL的"file.json“下载文件。在这里,我尝试在Python中使用这些代码,但是我得到了这个错误:
"code":400,"message":"Bucket is requester pays bucket but no user project provided"
在创建GCP帐户时,我已经设置了我的账单详细信息。我真的不知道怎么解决这个问题。我不是水桶的主人。我确实拥有从存储桶中获取数据的权限。Python代码:
import os
from google.cloud.bigquery.client import Client
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'path/to/key.json'
bq_client = Client()
import json
from google.cloud import storage
client = storage.Client(project='my_projectID')
bucket = client.get_bucket('the_bucket')
file_json = bucket.get_blob('file.json')
data = json.loads(file_json.download_as_string())
发布于 2021-10-25 12:13:37
您需要在请求中提供user_project,这是一个您有计费权限的gcp项目。然后,请求将被计入该项目。
您可以在此处找到python代码示例:https://cloud.google.com/storage/docs/using-requester-pays#using
bucket = storage_client.bucket(bucket_name, user_project=project_id)
在这里查看您在user_project中需要的权限:https://cloud.google.com/storage/docs/requester-pays#requirements
serviceusage.services.use
https://stackoverflow.com/questions/69706939
复制相似问题