Reputation: 10364
In the following code an mp3 file is successfully uploaded to a Firebase Bucket in a Cloud Function using Node.js according to the Extend Cloud Storage with Cloud Functions documentation, similar to the example image transformation. When the mp3 file is selected in the Firebase console or streamed on Android via ExoPlayer it plays as expected. However, the Metadata is not shown as uploaded in Firebase's console.
The CustomMetadata
object to be uploaded with the mp3 file per the Custom Metadata documentation. The use case is uploading an APIC
ID3
metadata tag with an mp3's image URL in order to consume by ExoPlayer on Android.
Firebase Console
Note: This is a portion of the full code for brevity.
The metadata location
and activity
are from the documentation example in order to test whether uploading custom metadata works.
...
.then(() => {
if (exists === false) {
return bucket.upload(tempAudioFile, {
destination: audioFilePath,
metadata: {
contentType: 'audio/mpeg',
customMetadata: {
'location': 'Yosemite, CA, USA',
'activity': 'Hiking'
}
}
})
} else {
throw new Error("Audiocast exists.")
}
})
...
Upvotes: 7
Views: 1558
Reputation: 151
The Cloud function syntax for custom metadata differs from the frontend library. Instead of customMetadata
, use the key metadata
. In your case:
metadata: {
contentType: 'audio/mpeg',
metadata: {
'location': 'Yosemite, CA, USA',
'activity': 'Hiking'
}
}
Upvotes: 15