[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[],[],null,["# Get a bucket's storage layout\n\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to determine the storage layout of your bucket. Storage\nlayout refers to how objects are organized within a bucket, either in a flat\nnamespace or a [hierarchical namespace](/storage/docs/hns-overview). The layout is important for\napplications that interact with the bucket, as object access and manipulation\nmethods vary depending on the layout. Storage layout also includes information\nabout the bucket's location.\n\nBy using the [`getStorageLayout`](/storage/docs/json_api/v1/buckets/getStorageLayout) API, your application can adapt its\nbehavior based on whether a bucket uses hierarchical namespace or not, ensuring\noptimal compatibility and leveraging the appropriate features based on the\nbucket configuration.\n\n#### Roles required\n\nIn order to get the required permissions for getting the storage layout of a Cloud Storage bucket , ask your administrator to grant you the Storage Object User (`roles/storage.objectUser`) role on the bucket.\n\nThe role contains the `storage.objects.list` permission, which is\nrequired to get the storage layout of the bucket.\n\nYou might also be able to get this permission with other [custom roles](/iam/docs/creating-custom-roles) or\n[predefined roles](/iam/docs/understanding-roles#predefined). To see which roles are associated with which permissions, refer to [IAM roles for Cloud Storage.](/storage/docs/access-control/iam-roles)\n\nFor instructions on granting roles on buckets, see [Use IAM with buckets.](/storage/docs/access-control/using-iam-permissions)\n\nGet a bucket's storage layout\n-----------------------------\n\n### Command line\n\nUse the [`gcloud alpha storage buckets describe`](/sdk/gcloud/reference/alpha/storage/buckets/describe) command with the `--format` flag: \n\n```\ngcloud alpha storage buckets describe gs://BUCKET_NAME --raw --format=\"default(hierarchicalNamespace)\"\n```\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the relevant bucket. For example, `my-bucket`.\n\nIf successful and hierarchical namespace is enabled, the response looks\nsimilar to the following example: \n\n```\n hierarchicalNamespace:\n enabled: true\n```\n\n### JSON API\n\n1. Have gcloud CLI [installed and initialized](/sdk/docs/install), which lets\n you generate an access token for the `Authorization` header.\n\n\n2.\n\n Use [`cURL`](http://curl.haxx.se/) to call the [JSON API](/storage/docs/json_api)\n with a [`getStorageLayout`](/storage/docs/json_api/v1/buckets/getStorageLayout) request: \n\n ```\n curl -X GET \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n \"https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/storageLayout\"\n ```\n\n Where \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e is the name of the\n relevant bucket. For example, `my-bucket`.\n\n If successful, the response looks like the following example:\n\n \u003cbr /\u003e\n\n ```json\n {\n \"kind\": \"storage#storageLayout\",\n \"bucket\": \"my-bucket\",\n \"location\": \"us-central1\",\n \"locationType\": \"region\",\n \"hierarchicalNamespace\":{enabled: true},\n }\n ```\n\n \u003cbr /\u003e\n\nWhat's next\n-----------\n\n- [Understand folders](/storage/docs/folders-overview).\n- [Create and manage folders](/storage/docs/create-folders).\n- [Rename folders](/storage/docs/rename-hns-folders).\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how\nCloud Storage performs in real-world\nscenarios. New customers also get $300 in free credits to run, test, and\ndeploy workloads.\n[Try Cloud Storage free](https://console.cloud.google.com/freetrial)"]]