0
0
Firebasecloud~30 mins

Why file storage is needed in Firebase - See It in Action

Choose your learning style9 modes available
Why File Storage is Needed in Firebase
📖 Scenario: You are building a simple app where users can upload and share photos. You need a place to keep these photos safe and accessible.
🎯 Goal: Understand why file storage is important by setting up a basic Firebase Storage structure to hold user files.
📋 What You'll Learn
Create a dictionary called files with example file names and sizes
Add a configuration variable max_file_size to limit upload size
Write a loop using for file_name, size in files.items() to check files against the limit
Add a final configuration storage_bucket to specify the Firebase Storage location
💡 Why This Matters
🌍 Real World
Apps like photo sharing, document storage, and music apps need file storage to save user content securely.
💼 Career
Understanding file storage setup is key for cloud developers managing user data and building scalable apps.
Progress0 / 4 steps
1
Create example file data
Create a dictionary called files with these exact entries: 'photo1.jpg': 1500, 'document.pdf': 3000, 'music.mp3': 5000
Firebase
Need a hint?

Use curly braces to create a dictionary with keys as file names and values as sizes in KB.

2
Add a max file size limit
Add a variable called max_file_size and set it to 4000 to limit the size of files that can be uploaded
Firebase
Need a hint?

Just create a variable and assign the number 4000 to it.

3
Check files against the size limit
Use a for loop with variables file_name and size to iterate over files.items() and check if each file size is less than or equal to max_file_size
Firebase
Need a hint?

Use a for loop to go through each file and an if statement to compare sizes.

4
Specify the Firebase Storage bucket
Add a variable called storage_bucket and set it to the string 'gs://myapp-uploads' to specify the Firebase Storage location
Firebase
Need a hint?

Set the storage_bucket variable to the Firebase Storage URL string.