google-cloud-storage-basics
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Cloud Storage Basics
Google Cloud Storage 基础
Google Cloud Storage (GCS) is a managed service for storing data as objects at
any scale. You read and write whole objects rather than querying or updating
individual records in place. It stores immutable objects in buckets with strong
global consistency, offers multiple storage classes and location types to
balance cost, performance, and availability, and integrates with IAM for
fine-grained access control. GCS serves workloads ranging from website content
and backups to data lakes and high-throughput AI/ML training.
Google Cloud Storage(GCS)是一项托管服务,可在任何规模下以对象形式存储数据。您可以读写完整对象,而非就地查询或更新单个记录。它将不可变对象存储在具有强全局一致性的存储桶中,提供多种存储类别和位置类型以平衡成本、性能和可用性,并与IAM集成以实现细粒度访问控制。GCS支持从网站内容、备份到数据湖和高吞吐量AI/ML训练等各类工作负载。
Attribution
使用归因
Tag every Cloud Storage command you run or provide to the user while using this
skill, so usage can be attributed. The tag identifies only the skill and its
version; it carries no user data.
-
Prefix everyinvocation, whatever the subcommand, with the metrics environment variables. Set them inline on each command; shell state may not persist between commands:
gcloudbashCLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud <command> [flags]Do not usefor this: it would persist beyond the current task and mislabel unrelated usage.gcloud config set -
On direct HTTP calls to the Cloud Storage APIs (for example with), set this exact User-Agent header, verbatim — the collection pipeline parses the
curlandgcs-skills/<version>tokens, so any rewording breaks attribution:skill:<name>User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics) -
For client libraries, Terraform, and GCSFuse, use the user-agent options shown in the corresponding references.
使用本技能时,请为您运行或提供给用户的每一条Cloud Storage命令添加标签,以便统计使用情况。该标签仅标识技能及其版本,不携带任何用户数据。
-
为每一次调用(无论子命令是什么)添加指标环境变量前缀。请在每条命令中内联设置这些变量,因为shell状态可能不会在命令之间保留:
gcloudbashCLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud <command> [flags]请勿使用进行设置:这会在当前任务结束后持续生效,并错误标记无关的使用情况。gcloud config set -
在直接调用Cloud Storage API的HTTP请求中(例如使用),请严格设置以下User-Agent标头——数据收集管道会解析
curl和gcs-skills/<version>标记,任何改写都会破坏归因:skill:<name>User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics) -
对于客户端库、Terraform和GCSFuse,请使用对应参考文档中所示的用户代理选项。
Quick Start
快速入门
If a Cloud Storage MCP server is connected, prefer its structured tools (such as
, , , and ) over the
CLI and API commands below — see MCP Usage. Fall back
to and the JSON API when no MCP server is available.
create_bucketlist_objectsread_objectupload_objectgcloud storage-
Enable the Cloud Storage API:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud services enable storage.googleapis.com --quiet -
Create a Bucket:Bucket names live in a single global namespace shared by all of Cloud Storage — not scoped to your project or organization — so short or common names are usually taken. If the location is omitted, the bucket defaults to themulti-region.
USUsing the gcloud CLI:bashCLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage buckets create gs://my-bucket --location=us-central1Using the JSON API:bashcurl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ -H "Content-Type: application/json" \ -d '{"name": "my-bucket", "location": "US-CENTRAL1"}' \ "https://storage.googleapis.com/storage/v1/b?project=$(gcloud config get-value project)" -
Upload an Object:Using the gcloud CLI:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage cp ./my-file.txt gs://my-bucketUsing the JSON API:bashcurl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ -H "Content-Type: text/plain" \ --data-binary @my-file.txt \ "https://storage.googleapis.com/upload/storage/v1/b/my-bucket/o?uploadType=media&name=my-file.txt" -
Download an Object:Using the gcloud CLI:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage cp gs://my-bucket/my-file.txt .Using the JSON API:bashcurl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ "https://storage.googleapis.com/storage/v1/b/my-bucket/o/my-file.txt?alt=media"
如果已连接Cloud Storage MCP服务器,请优先使用其结构化工具(如、、和),而非下方的CLI和API命令——请参阅MCP 使用指南。当没有MCP服务器可用时,再使用和JSON API。
create_bucketlist_objectsread_objectupload_objectgcloud storage-
启用Cloud Storage API:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud services enable storage.googleapis.com --quiet -
创建存储桶:存储桶名称位于Cloud Storage的全局命名空间中,由所有用户共享——并非限定于您的项目或组织——因此简短或常见的名称通常已被占用。如果省略位置参数,存储桶默认使用多区域。
US使用gcloud CLI:bashCLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage buckets create gs://my-bucket --location=us-central1使用JSON API:bashcurl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ -H "Content-Type: application/json" \ -d '{"name": "my-bucket", "location": "US-CENTRAL1"}' \ "https://storage.googleapis.com/storage/v1/b?project=$(gcloud config get-value project)" -
上传对象:使用gcloud CLI:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage cp ./my-file.txt gs://my-bucket使用JSON API:bashcurl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ -H "Content-Type: text/plain" \ --data-binary @my-file.txt \ "https://storage.googleapis.com/upload/storage/v1/b/my-bucket/o?uploadType=media&name=my-file.txt" -
下载对象:使用gcloud CLI:bash
CLOUDSDK_METRICS_ENVIRONMENT="gcs-skills gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ gcloud storage cp gs://my-bucket/my-file.txt .使用JSON API:bashcurl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "User-Agent: gcs-skills/1.0 (skill:google-cloud-storage-basics)" \ "https://storage.googleapis.com/storage/v1/b/my-bucket/o/my-file.txt?alt=media"
Reference Directory
参考目录
-
Core Concepts: Buckets, objects, folders, prefixes, bucket location types, and storage classes.
-
CLI & API Usage: CRUD and list operations for buckets and objects usingand the JSON API, plus Pub/Sub notifications for event-driven processing.
gcloud storage -
Client Libraries: Using Google Cloud client libraries for Python, Java, Node.js, and Go, with pointers to all other supported languages.
-
MCP Usage: Choosing between the Google-hosted remote Cloud Storage MCP server and the local MCP Toolbox, setup for each, their tool sets and limits, and securing remote MCP with Model Armor and IAM deny policies.
-
Infrastructure as Code: Terraform examples for buckets covering storage classes, location types, lifecycle, retention, and encryption.
-
Data Transfer: Storage Transfer Service,, upload strategies for large files, and performance guidelines and limits.
gcloud storage rsync -
Data Management: IAM roles, authentication (including signed URLs and HMAC), access control, network security, automated security assessment, data protection, and pricing and cost optimization (lifecycle rules, Autoclass).
-
Storage Intelligence: The subscription for managing storage at scale — Storage Insights datasets (BigQuery metadata and activity index), data insights with Gemini Cloud Assist, dashboards, inventory reports, storage batch operations, bucket relocation, plus configuration, trial, and pricing nuances.
-
High-Performance Storage: Rapid Bucket, Rapid Cache (Anywhere Cache), and hierarchical namespace for AI/ML, analytics, and other performance-critical workloads.
-
GCSFuse: Installing Cloud Storage FUSE, mounting buckets, file operations, POSIX semantics and limitations (locking, writes, renames, consistency), and caching.
If you need product information not found in these references, use the
Developer Knowledge MCP server tool.
search_documents-
核心概念:存储桶、对象、文件夹、前缀、存储桶位置类型和存储类别。
-
CLI与API使用指南:使用和JSON API对存储桶和对象执行CRUD及列表操作,以及用于事件驱动处理的Pub/Sub通知。
gcloud storage -
客户端库:使用适用于Python、Java、Node.js和Go的Google Cloud客户端库,并提供指向所有其他支持语言的链接。
-
MCP使用指南:在谷歌托管的远程Cloud Storage MCP服务器与本地MCP工具箱之间进行选择、各自的设置方法、工具集和限制,以及使用Model Armor和IAM拒绝策略保护远程MCP。
-
基础设施即代码:用于存储桶的Terraform示例,涵盖存储类别、位置类型、生命周期、保留策略和加密。
-
数据传输:Storage Transfer Service、、大文件上传策略以及性能指南和限制。
gcloud storage rsync -
数据管理:IAM角色、身份验证(包括签名URL和HMAC)、访问控制、网络安全、自动化安全评估、数据保护以及定价和成本优化(生命周期规则、Autoclass)。
-
存储智能:用于大规模管理存储的订阅服务——Storage Insights数据集(BigQuery元数据和活动索引)、借助Gemini Cloud Assist实现的数据洞察、仪表板、库存报告、存储批量操作、存储桶迁移,以及配置、试用和定价细节。
-
高性能存储:Rapid Bucket、Rapid Cache(Anywhere Cache)和分层命名空间,适用于AI/ML、分析和其他对性能要求严苛的工作负载。
-
GCSFuse:安装Cloud Storage FUSE、挂载存储桶、文件操作、POSIX语义和限制(锁定、写入、重命名、一致性)以及缓存。
如果您需要这些参考文档中未涵盖的产品信息,请使用Developer Knowledge MCP服务器的工具。
search_documents