Advertisement
Beginner Flutter, Cloud Firestore & Firebase Storage

What is Firebase Storage, and how does it complement Cloud Firestore by specifically handling the storage of larger files, such as images and videos?

Short answer

Firebase Storage is specifically designed for storing and serving larger binary files, such as user uploaded photos, videos, or documents, which are not well suited to being stored directly within a Firestore document due to Firestore's document size limits, and a common pattern…

Save Flutter mock interview
Advertisement
AModel answer
Firebase Storage is specifically designed for storing and serving larger binary files, such as user uploaded photos, videos, or documents, which are not well suited to being stored directly within a Firestore document due to Firestore's document size limits, and a common pattern pairs the two services together by uploading an actual file to Firebase Storage, then storing just a reference URL pointing to that uploaded file within a corresponding Firestore document, keeping the structured data and the larger binary file content each stored in the service best suited for it.
final ref = FirebaseStorage.instance.ref('profile_photos/$userId.jpg');
await ref.putFile(imageFile);
final downloadUrl = await ref.getDownloadURL();
Real-world example
A social media app uploads a user's profile photo to Firebase Storage, then saves only the resulting download URL string within that user's Firestore document, keeping their structured profile data lightweight while still supporting a full resolution profile photo.
Likely follow-ups
  • What are the security rules that control who can upload or download specific files in Firebase Storage?
  • How do you display an image stored in Firebase Storage within a Flutter widget?
Related topics