Enable Cloud Storage

Last Updated: 13 Nov 2021

Step 1: Get your Cloud Storage Bucket name for Firebase

Go to Firebase Console > Storage

Here, you will find your cloud storage bucket link for your Firebase Project. Copy that link

Step 2: Install gsutil

On Windows:

2. Before Finishing installation, make sure that the following are selected:

A Google Cloud SDK Shell terminal will appear. Let it initialize and then this line will appear:

To continue, you must login. Would you like to login (Y/n)?

Press Y to Sign In.

On other Operating Systems:

1. Install gsutil, follow this guide > https://cloud.google.com/storage/docs/gsutil_install#mac

Step 3: Set cors.json

2. Navigate to your Cloud SDK directory.

3. Paste the cors.json file at this location

4. Open Cloud SDK Shell Terminal and run this command:

gsutil cors set cors.json gs://<YOUR_CLOUD_STORAGE_BUCKET>

What is cors.json?

CORS (Cross-Origin Resource Sharing) can be simply defined as rules that allow or block access to specified domains.

The cors.json file that you downloaded earlier allows access to any domain: 



    "origin": ["*"],

    "method": ["GET"],

    "maxAgeSeconds": 3600



The asterisk "*" means that it will allow access to any domain. You can replace it with your own domain name and then run the gsutil cors set to apply the CORS.

Firebase Storage Rules:

These default rules mentioned above will allow to Upload or Download data only if the user is Signed In using Authentication.

Temporarily, for Testing Purposes, you can allow uploads and downloads even if user is not Authenticated using these rules given below:

rules_version = '2';

service firebase.storage {

  match /b/{bucket}/o {

    match /{allPaths=**} {

      allow read, write;




⚠️WARNING: This will make your database public (insecure), so anyone can get or modify any data. These rules are preferred when you are still developing your app.

If you are going to publish your app, you will need proper Security Rules to protect your database. To do so, check out this Doc:📄Secure Your Firebase Project.