0
0
Fluttermobile~20 mins

Cloud Storage for files in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cloud Storage Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
Uploading a file to Firebase Storage
What will happen when this Flutter code runs and the user selects a file to upload?
Flutter
final storageRef = FirebaseStorage.instance.ref().child('uploads/myfile.txt');
final file = File('/path/to/file.txt');
await storageRef.putFile(file);
final url = await storageRef.getDownloadURL();
print(url);
AThe file is uploaded to the root folder, ignoring the 'uploads/' path.
BThe code throws a runtime error because 'putFile' requires a Uint8List, not a File.
CThe file is uploaded to Firebase Storage under 'uploads/myfile.txt' and the download URL is printed.
DThe file is uploaded but the download URL is null because 'getDownloadURL' is not awaited.
Attempts:
2 left
💡 Hint
Check how the storage reference path and file upload method are used.
lifecycle
intermediate
2:00remaining
Handling upload progress in Flutter
Which code snippet correctly listens to upload progress events from Firebase Storage in Flutter?
Flutter
final storageRef = FirebaseStorage.instance.ref('uploads/photo.png');
final uploadTask = storageRef.putFile(file);
// Which code below correctly listens to progress?
A
uploadTask.onProgress.listen((progress) {
  print('Progress: $progress');
});
B
uploadTask.addListener(() {
  print('Upload progress');
});
C
uploadTask.events.listen((event) {
  print('Progress event');
});
D
uploadTask.snapshotEvents.listen((TaskSnapshot snapshot) {
  final progress = snapshot.bytesTransferred / snapshot.totalBytes;
  print('Progress: $progress');
});
Attempts:
2 left
💡 Hint
Look for the official property that streams upload snapshots.
🔧 Debug
advanced
2:00remaining
Fixing a permission denied error on upload
A Flutter app using Firebase Storage gets a 'permission denied' error when uploading files. Which Firebase Storage security rule causes this?
Flutter
rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
      allow write: if false;
    }
  }
}
AThe rule allows writes only if the user is authenticated, but the app is unauthenticated.
BThe rule denies all write operations because 'allow write: if false;' blocks uploads.
CThe rule syntax is invalid and causes all operations to fail.
DThe rule allows writes only on files smaller than 1MB, but the file is larger.
Attempts:
2 left
💡 Hint
Check the condition after 'allow write'.
🧠 Conceptual
advanced
2:00remaining
Understanding Firebase Storage download URLs
What is true about the download URL returned by Firebase Storage's getDownloadURL() method?
AIt is a public URL that anyone can use to access the file without authentication.
BIt requires the user to be authenticated to access the file.
CIt only works inside the Firebase app and cannot be used in browsers.
DIt expires after 1 hour and must be refreshed.
Attempts:
2 left
💡 Hint
Think about how Firebase Storage URLs are designed for sharing.
navigation
expert
3:00remaining
Managing file upload state across app navigation
In a Flutter app, a file upload starts on Screen A. The user navigates to Screen B before upload finishes. How to ensure upload progress updates still show on Screen B?
AUse a shared state management solution (like Provider or Riverpod) to hold the upload task and listen to its progress from both screens.
BStart a new upload task on Screen B to replace the one from Screen A.
CUse Navigator.popUntil to return to Screen A and show progress there only.
DUpload progress cannot be tracked after navigation; show a static message instead.
Attempts:
2 left
💡 Hint
Think about how to share data between screens in Flutter.