If your PHP 7 app needs to read and write files during runtime, or serve files such as movies, images or other static content, we recommend you use a Cloud Storage bucket.
App Engine creates a default bucket when you create an app. This bucket provides the first 5GB of storage for free and includes a free quota for Cloud Storage I/O operations. You can create other Cloud Storage buckets, but only the default bucket includes the first 5GB of storage for free.
Using Cloud Storage with App Engine
To use a Cloud Storage bucket from an App Engine app:
View the names of the existing buckets in your App Engine project. You'll specify these names when you upload or download data from Cloud Storage.
We recommend that you store the names of your Cloud Storage buckets in your app's environment variables instead of hard coding them into your app.
In your app, declare Cloud Storage as a dependency by adding
google/cloud-storageto your app's
composer.jsonfile and running
composer installfrom your app's directory. Learn more about specifying dependencies.
Google\Cloud\Storage\StorageClientas the stream wrapper for your app. Then use the
gsprotocol to read and write files.
As an alternative, you can use the Google Cloud client library directly.
Using the default bucket
When you create an app, App Engine creates a default bucket that provides the first 5GB of storage for free. The default bucket also includes a free quota for Cloud Storage I/O operations. See Pricing, quotas, and limits for details. You will be charged for storage over the 5GB limit.
The name of the default bucket is in the following format:
App Engine also creates a bucket that it uses for temporary
storage when it deploys new versions of your app. This bucket, named
staging.project-id.appspot.com, is for use by
App Engine only. Apps can't interact with this bucket.
Setting bucket and object permissions
The default service account that's associated with your app has all of the permissions required to read and write to buckets in your project.
To manage these permissions, each App Engine app uses a default service account that gives full read and write access to Cloud Storage buckets in the same project as the app. You can change the permissions of the default service account, but your app may lose access unless you assign an IAM role with the required permissions.
Using Cloud Storage with the local development server
The App Engine local development server doesn't emulate Cloud Storage, so all Cloud Storage requests must be sent over the Internet to an actual Cloud Storage bucket.
Pricing, quotas, and limits
There are no bandwidth charges associated with Cloud Storage client library calls to Cloud Storage. However, there are operations charges. In addition, the calls count against your URL fetch quota as the library uses the URL Fetch service to interact with Cloud Storage.
Notice that Cloud Storage is a pay-to-use service; you will be charged according to the Cloud Storage price sheet.