Your files are stored in a Firebase Storage bucket. The files in this bucket are presented in a hierarchical structure, just like the file system on your local hard disk, or the data in the Firebase Realtime Database.
By creating a reference to a file, your app gains access to it. These references can then be used to upload or download data, get or update metadata or delete the file. A reference can either point to a specific file or to a higher level in the hierarchy.
If you've used the Firebase Realtime Database, these paths should seem very familiar to you. However, your file data is stored in Google Cloud Storage not in the Realtime Database.
Create a reference to upload, download, or delete a file, or to get or update its metadata. A reference can be thought of as a pointer to a file in the cloud. References are lightweight, so you can create as many as you need. They are also reusable for multiple operations.
References are created using the
FirebaseStorage.service singleton instance
and calling either
For example to get a reference to the root of your storage tree:
Or you can pass a path to get a location lower in the tree:
Or you can use
child to navigate through your tree, the following is the equivalent of the above:
You can also use the
getRoot() methods to navigate up in our file hierarchy.
getParent() navigates up one level, while
getRoot() navigates all the way to the top.
child() these can all be chained together:
You can inspect references to better understand the files they point to using
getBucket() methods. These methods get the
file's full path, name and bucket.