Delete

Firestore trigger to delete file cloud storage
const admin = require("firebase-admin");
admin.initializeApp();
...
exports.deleteTranscriptMedia = functions.firestore
.document("transcripts/{transcriptId}")
.onDelete(async (snap, context) => {
const defaultStorage = admin.storage();
const deletedValue = snap.data();
const storageRefPath = deletedValue.storageRef;
const bucket = defaultStorage.bucket();
// const file = bucket.file('profilePicture/' + userID + '.png');
const file = bucket.file(storageRefPath);
// Delete the file
return file.delete()
});

Automatically delete your Firebase Storage Files from Firestore with Cloud Functions for Firebase