[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eThis page guides you on using the recommended Google Cloud Client Library APIs for Cloud Storage with App Engine, supporting environments beyond just App Engine.\u003c/p\u003e\n"],["\u003cp\u003ePHP 5 apps can use legacy App Engine APIs but are limited to App Engine and must upgrade to the recommended APIs for migration to newer App Engine runtimes.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine creates a default Cloud Storage bucket for each app, providing 5GB of free storage and a free quota for I/O operations, but only this default bucket offers free storage.\u003c/p\u003e\n"],["\u003cp\u003eTo use Cloud Storage, you need to list your bucket names, declare Cloud Storage as a dependency in your app using \u003ccode\u003ecomposer\u003c/code\u003e, and register \u003ccode\u003eGoogle\\Cloud\\Storage\\StorageClient\u003c/code\u003e as the stream wrapper to read and write files using the \u003ccode\u003egs\u003c/code\u003e protocol.\u003c/p\u003e\n"],["\u003cp\u003eWhile there are no bandwidth charges for Cloud Storage client library calls, operations charges apply, and these calls count against your URL fetch quota.\u003c/p\u003e\n"]]],[],null,["# Using Cloud Storage\n\n| **Key Point:** This page describes how to use the recommended APIs for Cloud Storage, which are in the [Google Cloud Client Library](https://googleapis.github.io/google-cloud-php/#/docs/cloud-storage/latest/storage/readme). These APIs enable your code to run in App Engine as well as other environments that support PHP 5.\n|\n| PHP 5 apps can continue to [use the legacy\n| App Engine APIs](/appengine/docs/legacy/standard/php/googlestorage), but such apps can only run in App Engine and will need to\n| upgrade to the recommended APIs before they can migrate to newer App Engine runtimes.\n\nIf your PHP 5 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\n\n by adding `google/cloud-storage` to your app's `composer.json` file and running\n `composer install` from your app's directory. Learn more about\n [composer](https://getcomposer.org).\n\n \u003cbr /\u003e\n\n3.\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### 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### Setting bucket and object 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/legacy/standard/php/service-account).\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/cloud-console#_bucketpermission)\nand\n[Setting object permissions](/storage/docs/cloud-console#_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)."]]