Uploading Files to Storage

Learn to upload files to a Cloud Storage bucket with Firebase.

To carry out any operation on a Cloud Storage bucket, we must create a referenceA reference is a pointer to a file on our database. to the specific path of the file—including a file nam—within our bucket. To do this, we use the ref function imported from the firebase/storage subpackage. This function returns a storage reference to the location in the bucket that corresponds to the provided URL.

The ref function takes the storage instance as its first argument. As an optional second parameter, it can take a URL to the file to which the reference will point. However, if no URL is provided, the function returns a reference to the root of the Storage bucket.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy