Get a bucket's storage layout

This page describes how to determine the storage layout of your bucket. Storage layout refers to how objects are organized within a bucket, either in a flat namespace or a hierarchical namespace. The layout is important for applications that interact with the bucket, as object access and manipulation methods vary depending on the layout. Storage layout also includes information about the bucket's location.

By using the getStorageLayout API, your application can adapt its behavior based on whether a bucket uses hierarchical namespace or not, ensuring optimal compatibility and leveraging the appropriate features based on the bucket configuration.

Get a bucket's storage layout

JSON API

  1. Have gcloud CLI installed and initialized, in order to generate an access token for the Authorization header.

    Alternatively, you can create an access token using the OAuth 2.0 Playground and include it in the Authorization header.

  2. Use cURL to call the JSON API with a getStorageLayout request:

    curl -X GET \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/storageLayout"

    Where BUCKET_NAME is the name of the relevant bucket. For example, my-bucket.

    If successful, the response looks like the following example:

      {
          "kind": "storage#storageLayout",
          "bucket": "my-bucket",
          "location": "us-central1",
          "locationType": "region",
          "hierarchicalNamespace":{enabled: true},
      }

What's next

Try it for yourself

If you're new to Google Cloud, create an account to evaluate how Cloud Storage performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.

Try Cloud Storage free