Firebase Storage

In-app chat system supports image sharing, the images are shared and uploaded through firebase storage. By default the Firebase storage is not enabled on your firebase, you need to create the firebase storage on your firebase.

To create a Firebase Storage in your Firebase project, follow these steps:

  1. Create a Firebase Project:

    • Go to the Firebase console at https://console.firebase.google.com/.

    • Click on "Add project" or select an existing project where you want to add Firebase Storage.

    • Follow the instructions to set up your project.

  2. Enable Firebase Storage:

    • Once your project is created or selected, click on "Build" from the left menu.

    • Select "Storage" from the options.

  3. Set Up Firebase Storage:

    • Click on the "Get Started" button.

    • Review the storage rules and modify them to use the rule stated at the bottom section of this page. These rules determine who can access your storage and what operations they can perform.

    • Click on "Next" to proceed.

  4. Choose a Storage Location:

    • Select the geographic location where you want your storage to be stored.

    • Firebase provides multiple options for storage locations.

    • Click on "Done" to complete the setup.

Firebase Storage Security

Same has setting security for the firebase firestore to protect your data, you also need to set security rules to protect images upload via chat to the firebase storage.

Below is the security rule that should be set for the firebase storage:

rules_version = '2';

// Craft rules based on data in your Firestore database
// allow write: if firestore.get(
//    /databases/(default)/documents/users/$(request.auth.uid)).data.isAdmin;
service firebase.storage {
  match /b/{bucket}/o {

    // This rule allows anyone with your Storage bucket reference to view, edit,
    // and delete all data in your Storage bucket. It is useful for getting
    // started, but it is configured to expire after 30 days because it
    // leaves your app open to attackers. At that time, all client
    // requests to your Storage bucket will be denied.
    //
    // Make sure to write security rules for your app before that time, or else
    // all client requests to your Storage bucket will be denied until you Update
    // your rules
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Last updated