Implementing file serving and downloading
In the previous recipe, we discussed how we could upload files to theStorage
bucket. In this part of the chapter, we're going to see how we can deliver and download our files directly from the Storage
bucket.
How to do it...
Typically, we don't have a way to showcase all the files we have within our bucket. We do have files and folders in Firebase; however there's no API to showcase folders, but only to showcase files.
Note
Bear in mind that the notion of folders doesn't have a meaning within the platform. This means that there's nothing called a folder within the API or logic--it's just a basic path reference to our files.
Thus, we need to have our own custom logic for the folder showcasing, typically a local database where you can save your basic files metadata. However, that is out of the scope of this chapter.
- As we did previously, we need to create ourselves a reference for the required file:
//Getting the file reference.
var rootRef ...