0
0
Firebasecloud~20 mins

Upload progress monitoring in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Upload Progress Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this Firebase upload progress code?

Consider this Firebase Storage upload snippet that tracks progress:

const uploadTask = storageRef.put(file);
uploadTask.on('state_changed', snapshot => {
  const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
  console.log(`Upload is ${progress}% done`);
});

What will be logged if 500 bytes are transferred out of 2000 bytes total?

Firebase
const snapshot = { bytesTransferred: 500, totalBytes: 2000 };
const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log(`Upload is ${progress}% done`);
AUpload is 100% done
BUpload is 50% done
CUpload is 75% done
DUpload is 25% done
Attempts:
2 left
💡 Hint

Calculate the percentage: (transferred / total) * 100.

Troubleshoot
intermediate
2:00remaining
Why does the Firebase upload progress event not fire?

A developer uses uploadTask.on('state_changed', ...) to track upload progress, but the callback never runs. What is the most likely cause?

AThe file variable is undefined or null
BThe Firebase Storage reference is missing a bucket name
CThe network connection is too fast to detect progress
DThe uploadTask variable is not assigned the result of <code>put()</code>
Attempts:
2 left
💡 Hint

Check if the file to upload is valid.

Configuration
advanced
2:30remaining
Which Firebase Storage rule allows upload progress monitoring for authenticated users only?

Given this Firebase Storage security rule snippet, which option correctly restricts uploads to authenticated users and allows progress monitoring?

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read: if true;
      allow write: if ...;
    }
  }
}
Arequest.resource.size &lt; 1000000
Brequest.auth != null
Crequest.time &lt; timestamp.date(2020, 1, 1)
Drequest.auth == null
Attempts:
2 left
💡 Hint

Authenticated users have a non-null request.auth.

🔀 Workflow
advanced
3:00remaining
What is the correct sequence to monitor and handle Firebase upload progress and completion?

Order these steps correctly for uploading a file with progress monitoring and completion handling in Firebase Storage:

A1,3,2,4
B3,1,2,4
C1,2,3,4
D2,1,3,4
Attempts:
2 left
💡 Hint

First create reference, then start upload, then listen for progress, then handle completion.

Best Practice
expert
3:00remaining
Which approach best improves user experience during large file uploads in Firebase Storage?

For large file uploads, which method best improves user experience by providing accurate progress feedback and allowing upload pause/resume?

ASplit the file manually into chunks and upload each chunk separately without pause support.
BUpload the file in one go without progress tracking to simplify code.
CUse <code>uploadTask.on('state_changed')</code> with pause() and resume() methods on uploadTask.
DUse a third-party library to upload files outside Firebase Storage.
Attempts:
2 left
💡 Hint

Firebase Storage uploadTask supports pause and resume natively.