Setting Up Google Cloud Storage

You can use a Cloud Storage bucket to store and serve files, such as movies or images or other static content. This document describes how to set up your environment to use the App Engine client library for Cloud Storage.

Setting up your project

Follow the instructions in Creating a Guestbook Application to set up your environment, create a Google Cloud project, and understand how Python 2 apps are structured in App Engine. Write down and save your project ID for use with your application.

Activating a Cloud Storage bucket

To use Cloud Storage, you'll need to activate at least one bucket. You might want to use the default bucket which provides the first 5GB of storage for free. You can always activate and use another Cloud Storage bucket if you want, but only the default bucket includes 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 more details.

To activate the default Cloud Storage bucket for your app:

  1. Click Create under Default Cloud Storage Bucket in the App Engine settings page for your project. Notice the name of this bucket: it is in the form <project-id>.appspot.com.

  2. If you need more storage than the 5GB limit, you can increase this by enabling billing for your project, making this a paid bucket. You will be charged for storage over the 5GB limit.

If you want to activate one or more paid buckets, follow the instructions under Creating a bucket to activate them.

Setting bucket and object permissions

You can find information on allowing your app's service account or other users access the storage bucket and its contents in Setting bucket permissions and Setting object permissions.

Downloading the client library

You can download the App Engine client library for Cloud Storage using popular tools like pip or Git. Alternatively, you can download the library manually from GitHub. Choose your preferred method:

Git

If you have Git installed, you can clone the GitHub repository for App Engine's Cloud Storage client library as follows:

git clone https://github.com/GoogleCloudPlatform/appengine-gcs-client.git

pip

If you have setuptools installed, you can use pip to download and install the App Engine client library for Cloud Storage as follows:

pip install GoogleAppEngineCloudStorageClient -t <your_app_directory/lib>

Manual download

You can download a ZIP file containing the App Engine client library for Cloud Storage from GitHub:

App Engine client library for Cloud Storage on GitHub

Install the library into the directory you are using for third-party libraries, such as lib. For more information, see Using third-party libraries.

Using the client library with the development app server

You can use the client library with the development server. However because there is no local emulation of Cloud Storage, all requests to read and write files must be sent over the Internet to an actual Cloud Storage bucket.

To use the client library with the development app server:

  1. Activate a Cloud Storage bucket.

  2. Run dev_appserver.py with the flag --default_gcs_bucket_name [BUCKET_NAME], replacing [BUCKET_NAME] with the name of the Cloud Storage bucket you are using.

    This flag controls the bucket that will be returned when your application calls file.DefaultBucketName(ctx).

Pricing, quotas, and limits

There are no bandwidth charges associated with making calls to Cloud Storage from App Engine's client library. 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 Google Cloud Storage is a pay-to-use service; you will be charged according to the Cloud Storage price sheet.

Alternative ways to access Cloud Storage

Instead of using the client library, you could use the following:

  • Cloud Storage Browser in the Google Cloud Console, which is useful for uploading objects quickly.
  • gsutil, which is a command-line tool for working with files in Cloud Storage.

What's next

Оцените, насколько информация на этой странице была вам полезна:

Оставить отзыв о...

Текущей странице
App Engine standard environment for Python 2