Hide
PHP

Setup

Your app requires a properly configured GCS bucket. Fortunately, each app can easily gain access to such a bucket. This bucket, called the default GCS bucket, needs no further configuration, permissions, sign-up, or activation. Moreover, the default GCS bucket has a free quota, so you do not need to make your app billable.

For apps created after the App Engine 1.9.0 release, the default GCS bucket is automatically created with your app.

For apps created before the App Engine 1.9.0 release, you can obtain a a default bucket for it by clicking Create within the Cloud Integration section in the Application Settings page of the App Engine Admin Console.

The default bucket name is typically <app_id>.appspot.com, where <app_id> is your app ID. You can find the bucket name in the App Engine Admin console Application Settings page, under the label Google Cloud Storage Bucket. Alternatively, you can use the CloudStorageTools::getDefaultGoogleStorageBucketName() method to find the name programmatically.

For example, you would write to the default bucket using the normal Cloud Storage stream wrapper:

<?php
file_put_contents('gs://<app_id>.appspot.com/hello.txt', 'Hello');

or

<?php
$fp = fopen('gs://<app_id>.appspot.com/some_file.txt', 'w');
fwrite($fp, 'Hello');
fclose($fp);