Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload progress #310

Open
Flaviano-Rodrigues opened this issue Oct 13, 2022 · 1 comment
Open

Upload progress #310

Flaviano-Rodrigues opened this issue Oct 13, 2022 · 1 comment

Comments

@Flaviano-Rodrigues
Copy link

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
Copy link

meshv-p commented Oct 31, 2022

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 
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants