Before running through the steps below, make sure that:
- You have activated your project for GCS and App Engine, including creating at least one GCS bucket.
- You have downloaded the client lib and installed it.
- You have installed the Cloud SDK.
Deploying and Running the Storage Example
To deploy and run the storage example:
- In your installation directory of the client library (typically
$GOPATH/src/google.golang.org/cloud/storage), choose either the App Engine example inexamples/storage/appengineor the Managed VMs example inexamples/storage/appenginevmandcdto that directory. - Open
app.yamland change theapplication:setting to your App Engine Application ID. - Upload the demo to your Cloud project by invoking
goapp:/path/to/AppEngSDK/goapp deploy -oauthorgcloud:/path/to/CloudSDK/gcloud --verbosity debug preview app deploy . - Follow the prompts to authorize deployments (if tokens have expired).
- Visit
http://<your-app-id-here>.appspot.comin your browser. -
You should see something like this:

Running the Storage Example Locally
To run the storage example locally:
- In your installation directory of the client library (typically
$GOPATH/src/google.golang.org/cloud/storage), choose either the App Engine example inexamples/storage/appengineor the Managed VMs example inexamples/storage/appenginevmandcdto that directory. - Open
app.goand override thebucketNamevariable with the bucket you wish to work with. For example, after the call tofile.DefaultBucketName, you could add a line that saysbucketName = "<your_app_id_here>.appspot.com". - From the Cloud console, download a private key by following these instructions.
- Convert the private key to
.pemformat by following these instructions and place the resulting file in your application directory. - Make note of the Service Account
Email Addressfor your project which will be in the form of<your_app_email_address>@developer.gserviceaccount.com. -
Run the demo locally by invoking
gcloud:/path/to/CloudSDK/gcloud app run . --appidentity-email-address <your_app_email_address>@developer.gserviceaccount.com --appidentity-private-key-path pem_file.pem
Finally, visit http://localhost:8080 in your browser, and you should see similar results to those shown above.
Understanding the Example
The code in the example is straightforward. The example creates files, lists bucket contents, and deletes files. It also manipulates ACLs for the bucket, for default objects, and for specific files.
The example also shows how to list a bucket in directory mode using the
Delimiter option to storage.Query.