Search code examples
firebasegoogle-cloud-firestorefirebase-admincloud-storage

How Can I get or create reference File in firebase-admin Storage


I'm working with Firebase-admin and I want to know how create or get reference of a File.

With this reference I'm going to save it in the Firestore with the reference data type.


Solution

  • This is what I would try (Typescript example):

    import * as admin from 'firebase-admin'
    
    admin
      .storage()
      .bucket()
      .file('path/to/myfile.jpg')
      .getMetadata()
      .then(apiResponse => {
        console.log(apiResponse)
      })