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
Command line
Use the gcloud alpha storage buckets describe
command with the --format
flag:
gcloud alpha storage buckets describe gs://BUCKET_NAME --raw --format="default(hierarchicalNamespace)"
Where:
BUCKET_NAME
is the name of the relevant bucket. For example,my-bucket
.
If successful and hierarchical namespace is enabled, the response looks similar to the following example:
hierarchicalNamespace: enabled: true
JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the
Authorization
header.Use
cURL
to call the JSON API with agetStorageLayout
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