From 055a1fed7945079c5b389df76fd4dbaabca84629 Mon Sep 17 00:00:00 2001 From: dblythy Date: Wed, 18 Nov 2020 00:22:34 +1100 Subject: [PATCH] Documentation for deleting files (#789) * Documentation for deleting files Closes #726 * Update files.md * Update files.md --- _includes/js/files.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_includes/js/files.md b/_includes/js/files.md index 46e3f3be8..2f04665e5 100644 --- a/_includes/js/files.md +++ b/_includes/js/files.md @@ -117,6 +117,16 @@ You can delete files that are referenced by objects using the [REST API]({{ site If your files are not referenced by any object in your app, it is not possible to delete them through the REST API. +Alternatively, starting with Parse Server 4.2.0, you can delete files using cloud code. + +```javascript +Parse.Cloud.beforeDelete('Profile', async (req) => { + const profile = req.object; + const profilePhoto = profile.get("photoFile"); + await profilePhoto.destroy({ useMasterKey: true }) +}); +``` + ## Adding Metadata and Tags Adding Metadata and Tags to your files allows you to add additional bits of data to the files that are stored within your storage solution (i.e AWS S3).