-
-
Notifications
You must be signed in to change notification settings - Fork 510
Documentation for deleting files (improvement) #791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
d61b9db
9cc311c
d425b11
ddb5cb1
3cf6398
5e6c8fa
b62ab67
6a63e8d
c320d7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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). | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.