gpt4 book ai didi

python-3.x - Cloud Storage python客户端无法检索存储桶

转载 作者:行者123 更新时间:2023-12-03 12:24:36 24 4
gpt4 key购买 nike

我正在尝试使用python客户端库将blob写入云存储。我正在使用的VM具有读/写权限以进行存储,并且能够通过gsutil访问存储桶,但是python给了我以下错误

>>> from google.cloud import storage
>>> storage_client = storage.Client()
>>> bucket = storage_client.get_bucket("gs://<bucket name>")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/google/cloud/storage/client.py", line 225, in get_bucket
bucket.reload(client=self)
File "/usr/local/lib/python3.5/dist-packages/google/cloud/storage/_helpers.py", line 108, in reload
_target_object=self)
File "/usr/local/lib/python3.5/dist-packages/google/cloud/_http.py", line 293, in api_request
raise exceptions.from_http_response(response)
google.api_core.exceptions.NotFound: 404 GET https://www.googleapis.com/storage/v1/b/gs://<bucket name>?projection=noAcl: Not Found

最佳答案

Phix是正确的。您只需要指定存储区名称,而无需使用'gs://'。实际上,可以找到https://www.googleapis.com/storage/v1/b/bucket被调用的API(例如Buckets:update here)。还有更多关于Python的Google Cloud Storage API client library和如何使用它的example的信息。

关于python-3.x - Cloud Storage python客户端无法检索存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53436615/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com