Delete
Firestore trigger to delete file cloud storage
1
const admin = require("firebase-admin");
2
admin.initializeApp();
3
...
4
exports.deleteTranscriptMedia = functions.firestore
5
.document("transcripts/{transcriptId}")
6
.onDelete(async (snap, context) => {
7
const defaultStorage = admin.storage();
8
const deletedValue = snap.data();
9
const storageRefPath = deletedValue.storageRef;
10
const bucket = defaultStorage.bucket();
11
// const file = bucket.file('profilePicture/' + userID + '.png');
12
const file = bucket.file(storageRefPath);
13
// Delete the file
14
return file.delete()
15
});
Copied!
Last modified 2yr ago
Copy link