Skip to content

Instantly share code, notes, and snippets.

@shangyilim
Created January 20, 2019 14:09
Show Gist options
  • Save shangyilim/e5d85edd58d728a6eb75145481183725 to your computer and use it in GitHub Desktop.
Save shangyilim/e5d85edd58d728a6eb75145481183725 to your computer and use it in GitHub Desktop.
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