Ramon
Ramon

Reputation: 501

Difference between bucket() and get_bucket() on google storage

I want to download the blobs on a google storage bucket. What is the difference between the get_bucket and the bucket methods a client has? Why do they differ in permissions? Can both be used to download blobs?

Upvotes: 4

Views: 2712

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75910

If you have a look to the code, you can see that

  • bucket() is simply a declaration, without any request to Cloud Storage to check if the bucket exist or not (you find the same logic with blob() method)
  • get_bucket() performs a call to Cloud Storage API to get the bucket with it's metadata (it's the same logic with get_blob())

In summary, with get_xxx you check the existence of the object, with the other method, you simply declare a name without checks.

With both, you can download the content of a Blob.

Upvotes: 8

Related Questions