0
0
Firebasecloud~10 mins

File metadata in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A'images/photo.jpg'
Bimages/photo.jpg
CstorageRef
D'storage/images/photo.jpg'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file path
Using a variable name instead of a string path
2fill in blank
medium

Complete 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'
Aimage/png
B'image/png'
C'text/plain'
DcontentType
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the MIME type
Passing the key name instead of the value
3fill in blank
hard

Fix 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'
AreadMetadata
BfetchMetadata
CdownloadMetadata
DgetMetadata
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names like fetchMetadata or readMetadata
Trying to access metadata without calling a method
4fill in blank
hard

Fill 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'
AcustomMetadata
BcontentType
CmetadataType
DcustomData
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid keys like 'metadataType'
Confusing contentType with custom metadata keys
5fill in blank
hard

Fill 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'
AcontentType
B'application/json'
CupdateMetadata
DsetMetadata
Attempts:
3 left
💡 Hint
Common Mistakes
Using setMetadata() which is not a Firebase Storage method
Forgetting quotes around the MIME type string