title: Empty file stored on Firebase with Python
body: <p>My goal is to generate certain files (txt/pdf/excel) on my Python server and subsequently push it to the Firebase Storage.</p>
  
  <p>For the Firebase Storage integration I use the pyrebase package.</p>
  
  <p>So far I have managed to generate the file locally and subsequently store it on the right path on the Firebase Storage database. </p>
  
  <p>However, the files I store are always empty. What is the reason for this?</p>
  
  <h1>1. Generating the localFile</h1>
  
  <pre><code>import os
  def save_templocalfile(specs):
  
  
      # Random something
      localFileName = "test.txt"
      localFile     = open(localFileName,"w+")
      for i in range(1000):
          localFile.write("This is line %d\r\n" % (i+1))
  
  
      return {
              'localFileName':    localFileName,
              'localFile':        localFile
          }
  </code></pre>
  
  <h1>2. Storing the localFile</h1>
  
  <pre><code># Required Libraries
  import pyrebase
  import time
  
  
  # Firebase Setup &amp; Admin Auth
  config = {
    "apiKey":        "&lt;PARAMETER&gt;",
    "authDomain":    "&lt;PARAMETER&gt;",
    "databaseURL":   "&lt;PARAMETER&gt;",
    "projectId":     "&lt;PARAMETER&gt;",
    "storageBucket": "&lt;PARAMETER&gt;",
    "messagingSenderId": "&lt;PARAMETER&gt;"
  }
  
  firebase    = pyrebase.initialize_app(config)
  storage     = firebase.storage()
  
  
  def fb_upload(localFile):
  
  
      # Define childref
      childRef      = "/test/test.txt"
      storage.child(childRef).put(localFile)
  
  
      # Get the file url
      fbResponse = storage.child(childRef).get_url(None)
  
  
      return fbResponse
  </code></pre>