Skip to content

Commit

Permalink
Documentation for deleting files (improvement) (parse-community#791)
Browse files Browse the repository at this point in the history
* improved JS doc for deleting file

* removed required reference to delete file

* changed bullet point to headline
  • Loading branch information
mtrezza committed Dec 7, 2020
1 parent 3191782 commit d368bd1
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions _includes/js/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,17 @@ 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 });
```

#### Parse Server <4.2.0

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).
Expand Down

0 comments on commit d368bd1

Please sign in to comment.