Created
January 20, 2019 14:09
-
-
Save shangyilim/e5d85edd58d728a6eb75145481183725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from "firebase-functions"; | |
import * as admin from "firebase-admin"; | |
const firebase = admin.initializeApp(); | |
export const deletePhotos = functions.firestore | |
.document("posts/{postId}") | |
.onDelete((snap, context) => { | |
const { postId } = context.params; | |
const bucket = firebase.storage().bucket(); | |
return bucket.deleteFiles({ | |
prefix: `images/${postId}` | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment