Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
Firebase Storage TypeScript error: Property 'on' does not exist on type 'Promise<UploadResult>'

I'm trying to implement a Vue Composable that uploads files to Firebase storage.

I am using the modular Firebase version 9 and implementing it by copying this example in their docs.

But that example uses plain JavaScript, and I want to implement it in TypeScript.

In my code below .on is throwing a TypeScript error that says Property 'on' does not exist on type 'Promise<UploadResult>'.

How to solve this?

import { projectStorage } from "@/firebase/config";
import { ref, watchEffect } from "vue";
import { ref as storageRef, uploadBytes } from "firebase/storage";

const useStorage = (file: File) => {
  watchEffect(() => {
    // references
    const storageReference = storageRef(projectStorage, "images/" + file.name);
    // upload file
    const uploadTask = uploadBytes(storageReference, file);
    // upload progress
    uploadTask.on("state_changed", (snapshot: any) => {
      console.log(snapshot);
    });
  });
};
export default useStorage;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You must use uploadBytesResumable() instead of uploadBytes() if you need to monitor upload progress.

uploadBytes() return a Promise containing an UploadResult and uploads are not resumable. With uploadBytesResumable(), the upload can be paused and resumed, and exposes progress updates.

You can find more information in the documentation.

import { ref as storageRef, uploadBytesResumable } from "firebase/storage";

const storageReference = storageRef(projectStorage, "images/" + file.name);
const uploadTask = uploadBytesResumable(storageReference, file);

uploadTask.on("state_changed", (snapshot: any) => {
  console.log(snapshot);
});
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!