Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a reference to the storage location.
Firebase
const storageRef = firebase.storage().ref().[1]('images/photo.jpg');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upload' instead of 'child' to create a reference.
Trying to use 'get' or 'delete' before creating the reference.
✗ Incorrect
The child method creates a reference to a specific file path in Firebase Storage.
2fill in blank
mediumComplete the code to upload a file to Firebase Storage.
Firebase
storageRef.[1](file).then(() => console.log('Upload complete'));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getDownloadURL' instead of 'put' to upload.
Trying to use 'delete' or 'listAll' which are unrelated to uploading.
✗ Incorrect
The put method uploads the file to the storage reference.
3fill in blank
hardFix the error in the code to get the download URL after upload.
Firebase
storageRef.put(file).then(() => storageRef.[1]()).then(url => console.log(url)); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upload' again instead of 'getDownloadURL'.
Trying to use 'delete' or 'list' which do not return URLs.
✗ Incorrect
After uploading, use getDownloadURL() to get the file's URL.
4fill in blank
hardFill both blanks to delete a file and then log a success message.
Firebase
storageRef.[1]().then(() => console.log([2]));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' instead of 'delete' to remove files.
Logging the wrong message after deletion.
✗ Incorrect
Use delete() to remove the file, then log a success message.
5fill in blank
hardFill all three blanks to upload a file, get its URL, and log it.
Firebase
storageRef.[1](file).then(() => storageRef.[2]()).then([3] => console.log([3]));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up method names or variable names.
Using 'delete' instead of 'put' or 'getDownloadURL'.
✗ Incorrect
First, put uploads the file. Then, getDownloadURL gets the URL. Finally, the URL is logged using the variable url.