Why is firebase.storage ref missing child() function (or other properties)?

Viewed 144

I imagine this should be a simple goal. I have some files stored in firebase, and I want to use validation like 'getDownloadUrl()' or 'child()' to navigate or confirm if file exists. That's kind of besides the point, though, as it seems my reference to my storage object is just missing some of the functions I expect to see, based on documentation and other google searches:

Here's the actual doc for the class: https://firebase.google.com/docs/reference/node/firebase.storage.Reference

So, assuming I have implemented this correctly, then I should be able to call the 'child()' function, right?

intellisense disagrees with docs

enter image description here

1 Answers

The new Firebase Modular SDK has a functional syntax rather than chaining method. That being said, you can just pass arguments in ref() to get a reference to child path as shown below:

const imageRef = ref(storage, "images", "1.png")

You can learn more about this syntax in the documentation (switch to 'modular' tab).


Similarly getDownloadURL is also a function now and must be imported from Firebase Storage SDK:

import { ref, getDownloadURL } from "firebase/storage"

const imageRef = ref(storage, "images", "1.png")

const url = await getDownloadURL(imageRef)
Related