Reputation: 853
I am trying to use the python client library to write blobs to cloud storage. The VM I'm using has Read/Write permissions for storage and I'm able to access the bucket via gsutil, however python is giving me the following error
>>> 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
Upvotes: 12
Views: 13723
Reputation: 623
Phix is right. You only need to specify the bucket name without the 'gs://'. As a matter of fact the API being called (e.g. Buckets: update https://www.googleapis.com/storage/v1/b/bucket) is found here. And here is more on Python's Google Cloud Storage API client library and an example of how to use it.
Upvotes: 15