How to do it...

  1. To upload a file, we need to first create a new reference to the created file. We already know that we got a reference to the root folder, as we saw it earlier in this chapter. The code for creating a new reference to the created file is as follows:
      //Creating a new reference for the uploaded file.      let imageRef = packtRef.child(`images/${<imageName>.         <ext>}`);
  1. You may wonder how can we programmatically create a folder. The current API doesn't have that capability, but Firebase does it automatically. This means that since we know we're pointing to a file that is in the images folder or any sub-folder, Firebase will go and create that folder for us dynamically.
Don't forget to add the filename and it's extension once you ...

Get Firebase Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.