snippets-web icon indicating copy to clipboard operation
snippets-web copied to clipboard

Upload progress

Open Flaviano-Rodrigues opened this issue 2 years ago • 1 comments

Can i get upload progress when upload a string like this ?


import { getStorage, ref, uploadString } from "firebase/storage";

const storage = getStorage();
const storageRef = ref(storage, 'some-child');

// Data URL string
const message4 = 'data:text/plain;base64,5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB';
const uploadTask = uploadString(storageRef, message4, 'data_url')

uploadTask.on('progress',()=>{
//get progress 
})

Flaviano-Rodrigues avatar Oct 13 '22 14:10 Flaviano-Rodrigues

Yea, you can get that.

uploadTask .on('state_changed', (snapshot) => {
            // Observe state change events such as progress, pause, and resume
            // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
            const progress = Math.floor((snapshot.bytesTransferred / snapshot.totalBytes) * 100);
            console.log('Upload is ' + progress + '% done', 'for ', file.name);
})

Can i get upload progress when upload a string like this ?

import { getStorage, ref, uploadString } from "firebase/storage";

const storage = getStorage();
const storageRef = ref(storage, 'some-child');

// Data URL string
const message4 = 'data:text/plain;base64,5b6p5Y+344GX44G+44GX44Gf77yB44GK44KB44Gn44Go44GG77yB';
const uploadTask = uploadString(storageRef, message4, 'data_url')

uploadTask.on('progress',()=>{
//get progress 
})

meshv-p avatar Oct 31 '22 05:10 meshv-p