我正在尝试使用 python 客户端库将 blob 写入云存储。我正在使用的虚拟机具有存储的读/写权限,并且我可以通过 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 https://stackoverflow.com/users/978005/phix是对的。您只需指定存储桶名称,无需指定“gs://”。事实上,正在调用的 API(例如 Buckets: updatehttps://www.googleapis.com/storage/v1/b/bucket https://www.googleapis.com/storage/v1/b/bucket)被发现here https://cloud.google.com/storage/docs/json_api/v1/buckets。这里有更多关于 Python 的内容Google Cloud Storage API 客户端库 https://pypi.org/project/google-cloud-storage/ and an example https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-python如何使用它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)