From b62ab670a18d3afaf785ac3b39745677f27db6c2 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Tue, 17 Nov 2020 14:55:20 +0100 Subject: [PATCH 1/3] improved JS doc for deleting file --- _includes/js/files.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/_includes/js/files.md b/_includes/js/files.md index 2f04665e5..7d5ee9747 100644 --- a/_includes/js/files.md +++ b/_includes/js/files.md @@ -113,20 +113,19 @@ Parse.Cloud.httpRequest({ url: profilePhoto.url() }).then(function(response) { ## Deleting Files -You can delete files that are referenced by objects using the [REST API]({{ site.baseUrl }}/rest/guide/#deleting-files). You will need to provide the master key in order to be allowed to delete a file. - -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. +You can delete files that are referenced by objects using the `destroy` method. The master key is required to delete a file. ```javascript -Parse.Cloud.beforeDelete('Profile', async (req) => { - const profile = req.object; - const profilePhoto = profile.get("photoFile"); - await profilePhoto.destroy({ useMasterKey: true }) -}); +const profilePhoto = profile.get("photoFile"); +await profilePhoto.destroy({ useMasterKey: true }); ``` +If your file is not referenced by any object in your app, it is not possible to delete it through Parse. + +* Parse Server <4.2.0 + +The `destroy` method is available since Parse Server 4.2.0, for lower versions use the [REST API]({{ site.baseUrl }}/rest/guide/#deleting-files) to delete a file. + ## 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). From 6a63e8ddfa55f1b6989818753ea0426d756f1003 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Thu, 19 Nov 2020 00:47:48 +0100 Subject: [PATCH 2/3] removed required reference to delete file --- _includes/js/files.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/_includes/js/files.md b/_includes/js/files.md index 7d5ee9747..bdc5f9f0f 100644 --- a/_includes/js/files.md +++ b/_includes/js/files.md @@ -120,8 +120,6 @@ const profilePhoto = profile.get("photoFile"); await profilePhoto.destroy({ useMasterKey: true }); ``` -If your file is not referenced by any object in your app, it is not possible to delete it through Parse. - * Parse Server <4.2.0 The `destroy` method is available since Parse Server 4.2.0, for lower versions use the [REST API]({{ site.baseUrl }}/rest/guide/#deleting-files) to delete a file. From c320d7eb58df213982d00d131d32cbb593de1593 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Fri, 27 Nov 2020 02:46:23 +0100 Subject: [PATCH 3/3] changed bullet point to headline --- _includes/js/files.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/js/files.md b/_includes/js/files.md index bdc5f9f0f..7408b565c 100644 --- a/_includes/js/files.md +++ b/_includes/js/files.md @@ -120,9 +120,9 @@ const profilePhoto = profile.get("photoFile"); await profilePhoto.destroy({ useMasterKey: true }); ``` -* Parse Server <4.2.0 +#### Parse Server <4.2.0 -The `destroy` method is available since Parse Server 4.2.0, for lower versions use the [REST API]({{ site.baseUrl }}/rest/guide/#deleting-files) to delete a file. +Use the [REST API]({{ site.baseUrl }}/rest/guide/#deleting-files) to delete a file. ## Adding Metadata and Tags