Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get a reference to a file in Firebase Storage.
Firebase
const storageRef = firebase.storage().ref().child([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file path
Using a variable name instead of a string path
✗ Incorrect
The file path must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to update the metadata of a file in Firebase Storage.
Firebase
storageRef.updateMetadata({ contentType: [1] }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the MIME type
Passing the key name instead of the value
✗ Incorrect
Metadata values like contentType must be strings with quotes.
3fill in blank
hardFix the error in the code to correctly fetch metadata of a file.
Firebase
storageRef.[1]().then(metadata => { console.log(metadata.contentType); }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like fetchMetadata or readMetadata
Trying to access metadata without calling a method
✗ Incorrect
The correct method to get metadata is getMetadata().
4fill in blank
hardFill both blanks to set custom metadata and then update it.
Firebase
const newMetadata = { [1]: 'user123', [2]: 'profile' };
storageRef.updateMetadata(newMetadata); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid keys like 'metadataType'
Confusing contentType with custom metadata keys
✗ Incorrect
Custom metadata keys are placed inside 'customMetadata' or similar keys; here 'customMetadata' and 'customData' are used as keys.
5fill in blank
hardFill all three blanks to correctly read, modify, and update file metadata.
Firebase
storageRef.getMetadata().then(metadata => {
const updatedMetadata = { ...metadata, [1]: [2] };
return storageRef.[3](updatedMetadata);
}); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using setMetadata() which is not a Firebase Storage method
Forgetting quotes around the MIME type string
✗ Incorrect
We update the 'contentType' to 'application/json' and call updateMetadata() to save changes.