[[["易于理解","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-08-21。"],[[["\u003cp\u003eCloud Storage is recommended for apps needing to read/write files or serve static content, with App Engine creating a default bucket providing 5GB of free storage.\u003c/p\u003e\n"],["\u003cp\u003eTo use Cloud Storage, you need to list the names of your project's existing buckets and consider storing them as environment variables in your app.\u003c/p\u003e\n"],["\u003cp\u003eVarious programming languages like Go, Java, Node.js, PHP, Python, and Ruby can utilize the Google Cloud Client Library to upload or download data from Cloud Storage buckets.\u003c/p\u003e\n"],["\u003cp\u003eThe service account associated with your app needs proper IAM permissions to read/write to buckets, and disabling automatic role grants is recommended, with safe role modification using Policy Simulator.\u003c/p\u003e\n"],["\u003cp\u003eThe App Engine local development server doesn't emulate Cloud Storage, and while there are no bandwidth charges for client library calls, operation charges and URL fetch quota usage apply.\u003c/p\u003e\n"]]],[],null,["# Use Cloud Storage\n\nGo Java Node.js PHP Python Ruby\n\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nIf your app needs to read and write files during runtime,\nor serve files such as movies, images or other static content, we recommend you\nuse a [Cloud Storage](/storage/docs) bucket.\n\nApp Engine creates a [default bucket](#default_bucket) when you create\nan app. This bucket provides the first 5GB of storage for free and includes a\nfree quota for Cloud Storage I/O operations. You can\n[create other Cloud Storage buckets](/storage/docs/creating-buckets),\nbut only the default bucket includes the first 5GB of storage for free.\n\nUsing Cloud Storage with App Engine\n-----------------------------------\n\nTo use a Cloud Storage bucket from an App Engine app:\n\n1. [View the names of the existing buckets](/storage/docs/listing-buckets)\n in your App Engine project. You'll specify these names when you\n upload or download data from Cloud Storage.\n\n We recommend that you store the names of your Cloud Storage buckets\n in your app's [environment variables](/appengine/docs/standard/reference/app-yaml#environment_variables)\n instead of hard coding them into your app.\n2. In your app, declare Cloud Storage as a dependency by doing the following:\n\n ### Go\n\n Using the `go get cloud.google.com/go/storage` command. Alternatively, you can declare\n dependencies in your app's `go.mod` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/go/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Java\n\n [Add the library to your app's dependencies file](/storage/docs/reference/libraries#client-libraries-install-java).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Node.js\n\n In `app.yaml`, add your project ID to the `GOOGLE_CLOUD_PROJECT` environment\n value. Then set the `GCLOUD_STORAGE_BUCKET` environment value to the name of\n the Cloud Storage bucket you created previously.\n\n Add `@google-cloud/storage` to your app's `package.json` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/nodejs/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n See the [`README.md` file](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/storage/standard/README.md)\n for instructions on running and testing locally.\n\n ### PHP\n\n Add `google/cloud-storage` to your app's `composer.json` file and running\n `composer install` from your app's directory. Learn more\n [about specifying dependencies](/appengine/docs/standard/php-gen2/specifying-dependencies).\n\n [Register `Google\\Cloud\\Storage\\StorageClient` as the\n stream wrapper](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.122.0/storage/storageclient?method=registerStreamWrapper) for your app.\n Then use the `gs` protocol to read and write files.\n\n See an [example of registering and using the stream\n wrapper](https://github.com/googleapis/google-cloud-php/tree/master/Storage#stream-wrapper).\n\n As an alternative, you can [use the Google Cloud client library directly](/storage/docs/reference/libraries).\n\n ### Python\n\n Add `google-cloud-storage` to your app's `requirements.txt` file. Learn more\n [about specifying dependencies](/appengine/docs/standard/python3/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n ### Ruby\n\n Add `google-cloud-storage` to your app's `Gemfile`. Learn more\n [about specifying dependencies](/appengine/docs/standard/ruby/specifying-dependencies).\n\n Use the Google Cloud Client Library to\n [upload](/storage/docs/uploading-objects)\n or [download](/storage/docs/downloading-objects)\n data from your buckets.\n\n For information about serving static content, see [Storing and Serving\n Static Files](/appengine/docs/standard/serving-static-files).\n\n### Using the default bucket\n\nWhen you create an app, App Engine creates a default bucket that\nprovides the first 5GB of storage for free. The default bucket also includes\na free quota for Cloud Storage I/O operations. See\n[Pricing, quotas, and limits](#pricing_quotas_and_limits) for details. You will\nbe charged for storage over the 5GB limit.\n\nThe name of the default bucket is in the following format: \n\n```\nproject-id.appspot.com\n```\n\n\u003cbr /\u003e\n\nApp Engine also creates a bucket that it uses for temporary\nstorage when it deploys new versions of your app. This bucket, named\n`staging.`\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e`.appspot.com`, is for use by\nApp Engine only. Apps can't interact with this bucket.\n\n### Set bucket permissions\n\nThe service account that's associated with your app needs permissions to read\nand write to buckets in your project. To learn which permissions are required,\nsee [IAM roles for\nCloud Storage](/storage/docs/access-control/iam-roles).\n\nTypically, the\nservice account that's associated with your app is the [default\nApp Engine service\naccount](/appengine/docs/standard/configure-service-accounts).\n\n\nDepending on your organization policy configuration, the default service account might\nautomatically be granted the [Editor role](/iam/docs/roles-overview#basic) on your\nproject. We strongly recommend that you disable the automatic role grant by [enforcing the `iam.automaticIamGrantsForDefaultServiceAccounts` organization policy\nconstraint](/resource-manager/docs/organization-policy/restricting-service-accounts#disable_service_account_default_grants). If you created your organization after May 3, 2024, this\nconstraint is enforced by default.\n\n\nIf you disable the automatic role grant, you must decide which roles to grant to the default\nservice accounts, and then [grant these\nroles](/iam/docs/granting-changing-revoking-access) yourself.\n\n\nIf the default service account already has the Editor role, we recommend that you replace the\nEditor role with less permissive roles.To safely modify the service account's roles, use [Policy Simulator](/policy-intelligence/docs/simulate-iam-policies) to see the impact of\nthe change, and then [grant and revoke the\nappropriate roles](/iam/docs/granting-changing-revoking-access).\n\n\u003cbr /\u003e\n\nFor information about allowing other users, apps, or projects to access a bucket\nand its contents, see\n[Setting bucket permissions](/storage/docs/access-control/using-iam-permissions).\n\nUsing Cloud Storage with the local development server\n-----------------------------------------------------\n\nThe App Engine local development server doesn't emulate Cloud Storage,\nso all Cloud Storage requests must be sent over the Internet to an\nactual Cloud Storage bucket.\n\nPricing, quotas, and limits\n---------------------------\n\nThere are no bandwidth charges associated with Cloud Storage client library\ncalls to Cloud Storage. However, there are\n[operations charges](/storage/pricing#operations-pricing).\nIn addition, the calls count against your\n[URL fetch quota](/appengine/docs/quotas#UrlFetch)\nas the library uses the URL Fetch service to interact with Cloud Storage.\n\nNotice that Cloud Storage is a pay-to-use service;\nyou will be charged according to the Cloud Storage\n[price sheet](/storage/pricing)."]]