Integrate with Google Cloud

If you have an*.appspot.com default bucket, your Firebase project must be upgraded to thepay-as-you-go Blaze pricing plan byFebruary 03, 2026 to maintain access to your default bucket.Learn more.Cloud Storage for Firebase is tightly integrated withGoogle Cloud. TheFirebase SDKs forCloud Storagestore files directly inGoogle Cloud Storage buckets,and as your app grows, you can integrate otherGoogle Cloud services,such as managed compute likeApp Engine or Cloud Functions, or machinelearning APIs like Cloud Vision or Google Translate.

A Firebase project is actually just aGoogle Cloud project that hasadditional Firebase-specific configurations and services enabled for it. Thismeans that everyCloud Storage bucket that you use withCloud Storage for Firebaseis accessible inGoogle Cloud (including its console and its APIs).

Considerations for service accounts

Firebase usesGoogle Cloud service accounts to operate and manage serviceswithout sharing user credentials. When you create a Firebase project that usesCloud Storage, you might notice that a corresponding service account isalready available in your project:service-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.com.For more information, seeFirebase service accounts overview.

Note: If yourCloud Storage buckets are managed under theservice account namedfirebase-storage@systeem.gserviceaccount.com, refer tothe Firebase support FAQ topicfor special instructions on service account setup.

Google Cloud Storage

You can use theGoogle Cloud Storage APIs to access files uploaded via theFirebase SDKs forCloud Storage, especially toperform more complex operations, such as copying or moving a file, or listingall the files available at a reference.

It's important to note that these requests useGoogle Cloud Storageaccess control options,rather thanFirebase Authentication andCloud Storage Security Rules.

APIs

In addition to theFirebase SDKs forCloud Storage, there are a number of other waysto access data stored in yourCloud Storage bucket, depending on what youwant to do. If you're accessing data on a server, we offer server sidelibraries, as well as aJSON and S3 compatibleXML RESTful API, or if youneed to script changes or perform other administrative tasks, we've got acommand line tool that will come in handy.

Google Cloud server SDKs

Google Cloud offers high-quality server SDKs for a number ofcloud products, includingCloud Storage. These libraries are available inNode.js,Java,go,Python,PHP,andRuby.

For more information, including installation instructions, authentication, andtroubleshooting, consult the platform-specific documentation linked above.

Example usage for theGoogle Cloud Storage SDK is shown below:

Node.js

// Require gcloudvargcloud=require('google-cloud');// EnableCloud Storagevargcs=gcloud.storage({projectId:'grape-spaceship-123',keyFilename:'/path/to/keyfile.json'});// Reference an existing bucket.varbucket=gcs.bucket('my-existing-bucket');// Upload a local file to a new file to be created in your bucket.bucket.upload('/photos/zoo/zebra.jpg',function(err,file){if(!err){// "zebra.jpg" is now in your bucket.}});// Download a file from your bucket.bucket.file('giraffe.jpg').download({destination:'/photos/zoo/giraffe.jpg'},function(err){});

Java

// EnableCloud StorageStoragestorage=StorageOptions.builder().authCredentials(AuthCredentials.createForJson(newFileInputStream("/path/to/my/key.json")).build().service();// Upload a local file to a new file to be created in your bucket.InputStreamuploadContent=...BlobIdblobId=BlobId.of("my-existing-bucket","zebra.jpg");BlobInfoblobInfo=BlobInfo.builder(blobId).contentType("text/plain").build();BlobzebraBlob=storage.create(blobInfo,content);// Download a file from your bucket.BlobgiraffeBlob=storage.get("my-existing-bucket","giraffe.jpg",null);InputStreamdownloadContent=giraffeBlob.getInputStream();

Go

// EnableCloud Storageclient,err:=storage.NewClient(ctx,option.WithServiceAccountFile("path/to/keyfile.json"))iferr!=nil{log.Fatal(err)}// Download a file from your bucket.rc,err:=client.Bucket("my-existing-bucket").Object("giraffe.jpg").NewReader(ctx)iferr!=nil{log.Fatal(err)}deferrc.Close()body,err:=ioutil.ReadAll(rc)iferr!=nil{log.Fatal(err)}

Python

    #Importgcloudfromgoogle.cloudimportstorage    #EnableCloudStorageclient=storage.Client()    #Referenceanexistingbucket.bucket=client.get_bucket('my-existing-bucket')    #Uploadalocalfiletoanewfiletobecreatedinyourbucket.zebraBlob=bucket.get_blob('zebra.jpg')zebraBlob.upload_from_filename(filename='/photos/zoo/zebra.jpg')    #Downloadafilefromyourbucket.giraffeBlob=bucket.get_blob('giraffe.jpg')giraffeBlob.download_as_string()

PHP

    // Require gcloud    require 'vendor/autoload.php';    use Google\Cloud\Storage\StorageClient;    // EnableCloud Storage    $storage = new StorageClient([        'projectId' => 'grape-spaceship-123'    ]);    // Reference an existing bucket.    $bucket = $storage->bucket('my-existing-bucket');    // Upload a file to the bucket.    $bucket->upload(        fopen('/photos/zoo/zebra.jpg', 'r')    );    // Download a file from your bucket.    $object = $bucket->object('giraffe.jpg');    $object->downloadToFile('/photos/zoo/giraffe.jpg');

Ruby

    #Requiregcloudrequire"google/cloud"    #EnableCloudStoragegcloud=Google::Cloud.new"grape-spaceship-123","/path/to/keyfile.json"storage=gcloud.storage    #Referenceanexistingbucket.bucket=storage.bucket"my-existing-bucket"    #Uploadafiletothebucket.bucket.create_file"/photos/zoo/zebra.jpg","zebra.jpg"    #Downloadafilefromyourbucket.file=bucket.file"giraffe.jpg"file.download"/photos/zoo/#{file.name}"

REST API

If you're using a language without a client library, want to do something thatthe client libraries don't do, or just have a favorite HTTP client that you'dprefer to use,Google Cloud Storage offers APIs for bothJSON andXML.

In addition to these storage data access APIs, to manage Cloud Storage bucketsfor use in Firebase projects, you can use theCloud Storage for Firebase API.

gsutil

gsutil is a commandline tool that gives you direct access toCloud Storage. You can usegsutilto do a wide range of bucket and object management tasks, including:

  • Uploading, downloading, and deleting objects.
  • Listing buckets and objects.
  • Moving, copying, and renaming objects.
  • Editing object and bucket ACLs.

gsutil allow for other advanced operations, such as moving files from onedirectory to another, or deleting all the files below a certain location.

Moving all the files from one reference to another is as easy as:

gsutil mv gs://bucket/old/reference gs://bucket/new/reference

Batch deleting all the files below a reference is similarly intuitive:

# Delete all files under a pathgsutil rm -r gs://bucket/reference/to/delete

# Delete all the files in a bucket but not the bucketgsutil rm -r gs://bucket/**

# Delete all the files AND the bucket# Removing the default bucket will break theFirebase SDKs forCloud Storage andis strongly discouragedgsutil rm -r gs://bucket

Request Rates

Google Cloud Storage is a highly scalable service that uses auto-scalingtechnology to achieve very high request rates.

Google Cloud Storage is a multi-tenant service, meaning that users sharethe same set of underlying resources. In order to make the best use of theseshared resources, buckets have an initial IO capacity.

As you plan to integrateCloud Storage for Firebase into your app, think abouta minimum request rate your app needs for good performance, and about makingrequests efficiently. Review guidelines aboutrequest rates,and especiallyramping up request rates.

Object Versioning

Have you ever deleted something by accident and not had a backup?Google Cloud Storage supportsObject Versioning,which provides an automatic way to back your data up, and restore from thosebackups. You can enable Object Versioning using thegsutilversioning setcommand:

gsutil versioning set on gs://<your-cloud-storage-bucket>

Cloud Storage always picks up the most recent version, so if you want torestore an object, you need to use one of the other APIs or tools above to setthe desired object as the most recent.

Object Lifecycle Management

Having the ability to automatically archive or delete stale files is a usefulfeature for many applications. Luckily,Google Cloud Storage providesObject Lifecycle Management,which allows you to delete or archive objects after a certain amount of time.

Consider a photo sharing application that you want all photos to be deletedwithin one day. You can set up an object lifecycle policy as follows:

// lifecycle.json{"lifecycle":{"rule":[{"action":{"type":"Delete"},"condition":{"age":1}}]}}

And deploy it using thegsutillifecycle set command:

gsutil lifecycle set lifecycle.json gs://<your-cloud-storage-bucket>

Note that this applies to all files in the bucket, so ifyou're storing important user backups you want to store for a long time alongside photos that you want to delete daily, you might want to use two separatebuckets or perform deletions manually withgsutil or your own server.

Google Cloud Functions (Beta)

Google Cloud Functions is alightweight, event-based, asynchronous compute solution that allows you tocreate small, single-purpose functions that respond to events without the needto manage a server or a runtime environment. These functions can be used fortranscoding video, classifying images using machine learning, or syncingmetadata with theFirebase Realtime Database. With even less overhead thanApp Engine, Cloud Functions is the fastest way to react to changes inCloud Storage.

Google Cloud Vision API

TheGoogle Cloud Vision API enablesdevelopers to understand the content of an image by encapsulating powerfulmachine learning models in an easy to use API. It quickly classifies images intothousands of categories, detects individual objects and faces within images,finds and reads printed words contained within images, identifies offensivecontent, and even provides image sentiment analysis.

Google Cloud Speech API

Similar to the Vision API, theGoogle Cloud Speech API enablesdevelopers to extract text from an audio file stored inCloud Storage.The API recognizes over 80 languages and variants, to support your global userbase. When combined with theGoogle Cloud Natural Language API,developers can both extract the raw text and infer meaning about that text.And if a global audience is required, couple this with theGoogle Translate API to translatethe text to 90+ languages.

GoogleApp Engine

This section aboutGoogleApp Engine is applicable only if youcreated your defaultCloud Storage bucket in your Firebase projectbeforeOctober 30, 2024 and the bucket has a name format ofPROJECT_ID.appspot.com.

GoogleApp Engine is a "Platform as a Service" that automaticallyscales backend logic in response to the amount of traffic it receives. Justupload your backend code and Google will manage your app's availability; thereare no servers for you to provision or maintain.App Engine is a fast andstraightforward way to add additional processing power or trusted execution toyour Firebase application.

If you have a defaultCloud Storage bucket with the name formatPROJECT_ID.appspot.com, then it's automatically shared with aApp Engine app in your project. This means that if you build anApp Engineapp, you can use the built-inApp Engine APIs to share data between thatbucket andApp Engine. This is useful for performing audio encoding,video transcoding, and image transformations, as well as other computationintensive background processing.

The Java, Python, and Gostandard environmentsforApp Engine include theApp Engine Images API(Java |Python |Go), which canresize, rotate, flip, and crop an image, as well as return an image serving URLwhich allows for client side transformations, similar to Cloudinary and Imgix.

When importing an existingGoogle Cloud project into Firebase, if you want tomake any existingApp Engine objects available in Firebase, you'll need to setthe default access control on your objects to allow Firebase to access them byrunning the following command usinggsutil:

gsutil-maclch-r-uservice-PROJECT_NUMBER@gcp-sa-firebasestorage.iam.gserviceaccount.comgs://BUCKET_NAME

Considerations forFirebase Security Rules andApp Engine files

If you have a defaultCloud Storage bucket with a name format of*.appspot.com, then your project also has anApp Engine app that shares that bucket.

If you configure yourFirebase Security Rules forpublic (unauthenticated) access,you will make newly uploadedApp Engine files publicly accessible, as well.

Known issues forCloud Storage andApp Engine

There are two known cases where you can't import yourApp Engine app:

  1. The project contains a formerApp EngineDatastore Master/Slave app.
  2. The project has a domain prefixed project ID, for example:domain.com:project-1234.

In either of these cases, the project won't supportCloud Storage for Firebase,and you should create a new Firebase project in order to useCloud Storage.Contact supportso that we can help you out.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-16 UTC.