title: Uploading fire to Firebase Storage using firebase-admin in Node
body: <p>I need to upload a file from a Node script to my Firebase storage using <code>firebase-admin</code>.</p>
  
  <p>This is how I'm <strong>doing in the browser: (IT WORKS)</strong></p>
  
  <pre><code>// THIS IS INSIDE A FUNCTION
  const storageRef = firebase.storage().ref('my-images/' + fileName);
  const uploadTask = storageRef.put(file,metadata);
  </code></pre>
  
  <p>This is how I'm <strong>TRYING to do in the Node script:</strong></p>
  
  <pre><code>const admin = require('firebase-admin');
  admin.initializeApp();
  
  // THIS IS INSIDE A FUNCTION
  const storageRef = admin.storage().ref('my-images/' + fileName);
  const uploadTask = storageRef.put(file,metadata);
  </code></pre>
  
  <p>And I'm getting the <strong>error:</strong></p>
  
  <pre><code>TypeError: admin.storage(...).ref is not a function
  </code></pre>
  
  <p><strong>I also tried:</strong></p>
  
  <pre><code>admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    storageBucket: "MY_BUCKET.appspot.com"
  });
  
  // THIS IS INSIDE A FUNCTION
  const storageRef = admin.storage().bucket().ref('my-images/' + fileName);
  const uploadTask = storageRef.put(file,metadata);
  </code></pre>
  
  <p>And I'm getting the <strong>error:</strong></p>
  
  <pre><code>TypeError: admin.storage(...).bucket(...).ref is not a function
  </code></pre>
  
  <p><strong>QUESTION</strong></p>
  
  <p>I need to save the file in my default bucket inside the <code>my-images</code> folder. What is the proper way of doing it?</p>