Giter Site home page Giter Site logo

firebasestoragewrapperpython's Introduction

Summary

This project is using: https://github.com/AsifArmanRahman/firebase-rest-api

Firebase-rest-api to manage file uploading / downloading from FileStorage.

Meaning you should do: pip install firebase-rest-api

And potentially whatever other pip errors get thrown at you.

Setup

Firebase Project > Users and Permissions

Under General

  1. Add a new app for Web

You'll get an object like this:

 firebaseConfig = {
  apiKey: "x",
  authDomain: "x.firebaseapp.com",
  projectId: "x",
  storageBucket: "x.appspot.com",
  messagingSenderId: "x",
  appId: "1:x:web:x",
  measurementId: "G-x"
};

Under Service Accounts

  1. Generate a new private key

You will get a JSON file to download and put to your project. You can also just directly paste in the JSON under the service account rather than the file. I ended up doing that nowadays.

dir_path = os.path.dirname(os.path.realpath(__file__))
credentials_path = os.path.join(dir_path, "firebase_credentials.json")

if not os.path.exists(credentials_path):
    raise FileNotFoundError(
        f"Firebase credentials file not found at {credentials_path}"
    )

config={
        # initialized this through creating a "web app"
        apiKey: "x",
        authDomain: "x.firebaseapp.com",
        projectId: "x",
        storageBucket: "x.appspot.com",
        messagingSenderId: "x",
        appId: "1:x:web:x",
        measurementId: "G-x"
        # This is for real time database url so can leave empty.
        "databaseURL": "",
        # This is specifically the admin level
        # "serviceAccount": credentials_path,  # Initialized this through firebase instructions
        "serviceAccount": "firebase_credentials.json" # this is another option, cause on runpod the __file__ was causing issue, so I just gave it the direct relative directory
    }

firebaseSimpleManager = SimpleFirebaseManager(config)
firebaseSimpleManager.upload_file("mock.mp3", "media/output.mp3")
firebaseSimpleManager.download_file("media/output.mp3", "test_download.mp3")

firebasestoragewrapperpython's People

Contributors

justinwlin avatar

Stargazers

ec-admin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.