Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara menentukan tata letak penyimpanan bucket Anda. Tata letak penyimpanan mengacu pada cara objek disusun dalam bucket, baik dalam namespace datar atau namespace hierarkis. Tata letak penting untuk aplikasi yang berinteraksi dengan bucket, karena metode akses dan manipulasi objek bervariasi bergantung pada tata letaknya. Tata letak penyimpanan juga mencakup informasi tentang lokasi bucket.
Dengan menggunakan getStorageLayout API, aplikasi Anda dapat menyesuaikan
perilakunya berdasarkan apakah bucket menggunakan namespace hierarkis atau tidak, sehingga memastikan
kompatibilitas yang optimal dan memanfaatkan fitur yang sesuai berdasarkan
konfigurasi bucket.
Peran yang diperlukan
Untuk mendapatkan izin yang diperlukan guna mendapatkan tata letak penyimpanan bucket Cloud Storage , minta administrator Anda untuk memberi Anda peran Storage Object User (roles/storage.objectUser) di bucket tersebut.
Peran ini berisi izin storage.objects.list, yang diperlukan untuk mendapatkan tata letak penyimpanan bucket.
Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi
performa Cloud Storage dalam skenario
dunia nyata. Pelanggan baru mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[],[],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)"]]