diff --git a/controller/media.ts b/controller/media.ts index 0bb9ba6..6401f2a 100644 --- a/controller/media.ts +++ b/controller/media.ts @@ -28,4 +28,13 @@ export const getMediaObject = (assetId: string) => Media.findOne({assetId}); * @param assetId The id of the asset to pipe * @param res The express response controller */ -export const pipeMedia = (assetId: string, res: Response) => bucket.file(assetId).createReadStream().pipe(res); \ No newline at end of file +export const pipeMedia = (assetId: string, res: Response) => bucket.file(assetId).createReadStream().pipe(res); + +/** + * Deletes the provided asset from the database & bucket + * @param assetId The id of the asset to delete + */ +export const deleteMedia = async (assetId: string) => { + await Media.deleteOne({assetId}); + await bucket.file(assetId).delete(); +} \ No newline at end of file