Back

Not fully file/document delete case

  • 1
  • Android
  • Databases
  • Storage
  • Cloud
retr122
17 Aug, 2023, 04:23

Imagine a situation - a user deletes a file from storage, but during the procedure the Internet is turned off, and although the file is deleted, the mention of ITS FILE ID in other documents remains and users may encounter problems. What to do in such cases? Is it possible to check if a File/Document exists in an Appwrite project?

TL;DR
You can use an Appwrite function to handle the situation where a file is deleted but its File ID is still mentioned in other documents. The function can run when the `buckets.*.files.*.delete` event is triggered. It can get the details of the deleted file from an environment variable and perform operations like deleting related documents or updating user preferences. To check if a File/Document exists in an Appwrite project, you can use the Appwrite API and make a GET request to the specific endpoint for files or documents.
safwan
17 Aug, 2023, 06:15

There's a lot of ways to go about this, but the best way would be to use an appwrite function.

To make sure I understand you correctly, you have a file who's File ID is in document. This document may or may not have other details of the file. Regardless, you can create a function that runs when the buckets.*.files.*.delete event is triggered.

This function would get the details of the file that was deleted in an environment variable. Use these details to get the File ID, and perform any operations you want - delete a document, update a user preference, etc.

safwan
17 Aug, 2023, 06:16

For more details about Appwrite Functions, have a read through the guide: https://appwrite.io/docs/functions

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more