Implementing file metadata updates
So typically, any kind of file--or folder for that matter--has what we call metadata. That vital information is present to help recognize the nature of the file and its type. It's what we normally refer to for adding MIME types, and files in the Firebase Storage bucket are no exception. Within the platform, the possibilities present are let us retrieve and also update the file's metadata, and in this recipe, we're going to see how we can do just that.
How to do it...
- Let's start first with retrieving metadata. To allow us to do so, the Firebase APIs provide us with a function called
getMetadata()
. This function will allow for the retrieving of all file metadata in one place, but first, let's grab a file reference as we did in the earlier recipes:
//Grab a reference for the Root Directory. let rootRef = firebase.storage().ref(); //Let's grab a reference for our file. let imageRef = rootRef.child('path-to-file/<file- name>...