Added deleteMedia to the media controller

This commit is contained in:
2022-09-09 15:59:43 +02:00
parent 4afba19ee9
commit 99b6102847

View File

@ -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);
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();
}