Upload task (advanced)
working with the upload task
we may track the upload progress. For each tick, we receive a snapshot.
const uploadTask = uploadBytesResumable(ref, file)
uploadTask.on(
"state_changed",
function (snapshot) {
let progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100
console.log("Upload is " + progress + "% done")
setProgress(progress)
switch (snapshot.state) {
case "paused":
console.log("Upload is paused")
break
case "running":
console.log("Upload is running")
break
default:
break
}
},
function (error) {},
function () {
getDownloadURL(uploadTask.snapshot.ref).then(function (downloadURL) {
console.log("File available at", downloadURL)
})
}
)