Search code examples
google-cloud-platformgoogle-cloud-storage

GCP Cloud Storage REST API endpoint is always "https://storage.googleapis.com/<bucket_name>"?


I had a question while testing the REST APIs of AWS S3 and GCP Cloud Storage.

AWS S3 REST api endpoint is equal to s3 bucket endpoint

ex) https://s3.ap-northeast-2.amazonaws.com/<bucket_name>

But GCP Cloud Storage REST api endpoint is different from GCP Cloud bucket endpoint

ex) bucket endpoint
https://storage.cloud.google.com/<bucket_name>

ex) REST api endpoint
https://storage.googleapis.com/<bucket_name>

I am confused due to the above differences, but if I were to ask, is the CCP Cloud Storage REST API endpoint always fixed? Is there absolutely no possibility of it changing?

if it does change, please explain under what circumstances it changes.


Solution

  • https://storage.googleapis.com/<bucket_name>/ is the default URL choice for GCS. It uses what's documented as the GCS XML API. It works with web browsers and client libraries.

    https://storage.cloud.google.com/<bucket_name> is a special purpose domain pattern. It allows you to use your browser's google.com cookies as a credential, so if you're logged in to your Google account and your account has access to that bucket, you can access your stuff at that URL. For security reasons, access to this endpoint has several additional restrictions that are not necessary on other endpoints. It's useful if you need to view your own objects with a web browser, but for most GCS use cases (like when you're writing a program to access resources or serving data to anonymous users), it's probably not the URL you want.