Functions on other events
on Firestore events
Cloud functions triggered by a database event are non-blocking: they run after the write.
sanitize data post-write
// v1 syntax
exports.myFunction = functions.firestore
.document("my-collection/{docId}")
.onWrite((change, context) => {
/* ... */
})
on Storage events
sanitize data post-upload
the user uploads a file to Firebase Storage. Sanitize data post-upload. For exampeL
exports.generateThumbnail = functions.storage.object().onFinalize(async (object) => {
const fileBucket = object.bucket
// The Storage bucket that contains the file.
const filePath = object.name
// File path in the bucket.
const contentType = object.contentType
// File content type.
const metageneration = object.metageneration
// Number of times metadata has been generated. New objects have a value of 1.
})