Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
É possível usar um bucket do Cloud Storage para armazenar e exibir arquivos, como filmes, imagens ou outros conteúdos estáticos. Neste documento, descrevemos como configurar seu ambiente para usar a biblioteca de cliente do App Engine para Cloud Storage.
Configurar o projeto
Crie um projeto do Google Cloud e entenda como os apps Go 1.11 são
estruturados no App Engine. Anote e guarde o ID do projeto para uso com seu aplicativo.
Como ativar um bucket do Cloud Storage
Para usar o Cloud Storage, é preciso ativar pelo menos um bucket.
Você pode usar o bucket padrão que fornece gratuitamente os primeiros 5 GB de armazenamento. É possível ativar e usar outro bucket do
Cloud Storage. O bucket padrão inclui
os primeiros 5 GB de armazenamento sem custos. O bucket padrão também inclui uma cota gratuita para operações de E/S do Cloud Storage. Consulte Preços, cotas e limites para mais detalhes.
Para ativar o bucket padrão do Cloud Storage para seu aplicativo:
Clique em Criar na seção bucket padrão do Cloud Storage da página Configurações do App Engine no projeto.
Observe o nome desse bucket: ele está no formato <project-id>.appspot.com.
Se você precisar de mais armazenamento, além do limite de 5 GB, é possível aumentá-lo ativando o faturamento do seu projeto. Assim, ele se tornará um bucket pago e você será cobrado pelo armazenamento que exceder o limite dos 5 GB.
Se quiser ativar um ou mais buckets pagos, siga as instruções em Como criar um bucket.
Como usar a biblioteca de cliente com o servidor do aplicativo de desenvolvimento
É possível usar a biblioteca de cliente com o servidor de desenvolvimento. No entanto, como não há emulação local do Cloud Storage, todas as solicitações de leitura e gravação de arquivos precisam ser enviadas pela Internet para um bucket real do Cloud Storage.
Para usar a biblioteca de cliente com o servidor do aplicativo de desenvolvimento:
Execute dev_appserver.py com a sinalização --default_gcs_bucket_name [BUCKET_NAME],
substituindo [BUCKET_NAME] pelo nome do bucket do Cloud Storage que você está
usando.
Essa sinalização controla o bucket que será retornado quando o aplicativo
chamar file.DefaultBucketName(ctx).
Preços, cotas e limites
Não há cobranças de largura de banda associadas à realização de chamadas ao Cloud Storage a partir da biblioteca de cliente do App Engine. No entanto, há cobranças de operações.
Além disso, as chamadas são contabilizadas na
cota de busca de URL,
uma vez que a biblioteca usa o serviço de busca de URL para interagir com o Cloud Storage.
O Cloud Storage é um serviço pago.
Você será cobrado de acordo com a tabela de preços desse serviço.
Alternativas de acesso ao Cloud Storage
Em vez de usar a biblioteca de cliente, você pode usar as seguintes opções:
Navegador do Cloud Storage no
console doGoogle Cloud , que é útil para fazer upload de objetos rapidamente.
A ferramenta gsutil para trabalhar com arquivos no Cloud Storage usando linhas de comando
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-03 UTC."],[[["\u003cp\u003eCloud Storage buckets can be used to store and serve static content like movies or images, and this document details setting up the environment to use the App Engine client library for Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eTo use Cloud Storage, you must activate at least one bucket, with the default bucket offering 5GB of free storage and a free quota for I/O operations.\u003c/p\u003e\n"],["\u003cp\u003eThe App Engine client library for Cloud Storage can be downloaded using the \u003ccode\u003ego\u003c/code\u003e tool, allowing you to interact with Cloud Storage from your application.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the client library with the development app server, all read and write requests are sent over the Internet to a real Cloud Storage bucket, and the \u003ccode\u003edev_appserver.py\u003c/code\u003e must include a flag specifying the bucket name.\u003c/p\u003e\n"],["\u003cp\u003eWhile there are no bandwidth charges for calls from App Engine's client library to Cloud Storage, there are operations charges, and these calls count against the URL fetch quota.\u003c/p\u003e\n"]]],[],null,["# Setting Up Google Cloud Storage\n\nYou can use a Cloud Storage bucket\nto store and serve files, such as movies or images or other static content. This\ndocument describes how to set up your environment to use the App Engine client\nlibrary for Cloud Storage.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| go\n| /services/access). If you are updating to the App Engine Go 1.12+ runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/go-differences) to learn about your migration options for legacy bundled services.\n\nSetting up your project\n-----------------------\n\nCreate a Google Cloud project, and understand how Go 1.11 apps are\nstructured in App Engine. Write down and save your project ID for use\nwith your application.\n\nActivating a Cloud Storage bucket\n---------------------------------\n\nTo use Cloud Storage, you'll need to activate at least one bucket.\nYou might want to use the default bucket which provides the first 5GB of\nstorage for free. You can activate and use another Cloud Storage\nbucket. The default bucket includes\nthe first 5GB of storage for free. The default bucket\nalso includes a free quota for Cloud Storage I/O operations. See\n[Pricing, quotas, and limits](#pricing_quotas_and_limits)\nfor more details.\n\nTo activate the default Cloud Storage bucket for your app:\n\n1. Click **Create** under *Default Cloud Storage Bucket* in the\n [App Engine settings](https://console.cloud.google.com/appengine/settings) page for your project.\n Notice the name of this bucket: it is in the form `\u003cproject-id\u003e.appspot.com`.\n\n2. If you need more storage than the 5GB limit, you can\n increase this by [enabling billing](https://console.cloud.google.com/billing) for your project,\n making this a paid bucket. You will be charged for storage over the 5GB limit.\n\nIf you want to activate one or more paid buckets, follow the instructions under\n[Creating a bucket](/storage/docs/cloud-console#_creatingbuckets) to activate\nthem.\n| **Note:** When you create a default bucket, you also get a staging bucket with the same name except that `staging.` is prepended to it. You can use this staging bucket for temporary files used for staging and test purposes; it also has a 5 GB limit, but it is automatically emptied on a weekly basis.\n\n### Setting bucket and object permissions\n\nYou can find information on allowing your app's service account or other users\naccess the storage bucket and its contents in\n[Setting bucket permissions](/storage/docs/cloud-console#_bucketpermission) and\n[Setting object permissions](/storage/docs/cloud-console#_permissions).\n\nDownloading the client library\n------------------------------\n\nThe App Engine client library for Cloud Storage is available via the `go` tool.\nTo download the library:\n\n1. Set your `GOPATH` if needed. If you are using Linux and macOS, you can\n set your `GOPATH` as follows:\n\n mkdir -p $HOME/go\n export GOPATH=$HOME/go\n\n | **Note:** For Windows instructions, see the [Windows](https://golang.org/doc/install#windows) section of [Getting Started with the Go Programming Language](https://golang.org/doc/install).\n2. Download the `oauth2`, `storage`, and `appengine` packages:\n\n go get -u golang.org/x/oauth2\n go get -u cloud.google.com/go/storage\n go get -u google.golang.org/appengine/...\n\n | **Note:** These packages will be downloaded to your `GOPATH`'s `src` directory.\n\nFor details about installing the client library, see the [Cloud Storage Client Libraries](/storage/docs/reference/libraries) page.\n\nUsing the client library with the development app server\n--------------------------------------------------------\n\nYou can use the client library with the development server. However because\nthere is no local emulation of Cloud Storage, all requests to read and write\nfiles must be sent over the Internet to an actual Cloud Storage bucket.\n\nTo use the client library with the development app server:\n\n1. [Activate a Cloud Storage bucket](#activating_a_cloud_storage_bucket).\n\n2. Run `dev_appserver.py` with the flag `--default_gcs_bucket_name [BUCKET_NAME]`,\n replacing `[BUCKET_NAME]` with the name of the Cloud Storage bucket you are\n using.\n\n This flag controls the bucket that will be returned when your application\n calls `file.DefaultBucketName(ctx)`.\n\nPricing, quotas, and limits\n---------------------------\n\nThere are no bandwidth charges associated with making calls to Cloud Storage from\nApp Engine's client library. 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 [price sheet](/storage/pricing).\n\nAlternative ways to access Cloud Storage\n----------------------------------------\n\nInstead of using the client library, you could use the following:\n\n- [Cloud Storage Browser](https://console.cloud.google.com/storage/browser) in the Google Cloud console, which is useful for uploading objects quickly.\n- [gsutil](/storage/docs/gsutil), which is a command-line tool for working with files in Cloud Storage.\n\nWhat's next\n-----------\n\n- Visit the [API Reference documentation](https://godoc.org/cloud.google.com/go/storage).\n- Learn how to [read and write to Cloud Storage](/appengine/docs/legacy/standard/go111/googlecloudstorageclient/read-write-to-cloud-storage) with the App Engine client library for Cloud Storage.\n- Review the [App Engine and Google Cloud Storage sample](/appengine/docs/legacy/standard/go111/googlecloudstorageclient/app-engine-cloud-storage-sample).\n- View the complete set of [Cloud Storage documentation](/storage/docs), including additional samples and tutorials."]]