I want to delete files in my bucket which are more than 1 day old. So how can I do so? I thought to write a function to delete files and use cron to execute it, but by doing that I wouldn't be able to delete files after 1 day is completed. So how can I do that?
You will need a scheduled function. You can easily schedule them from dashboard
In setting tabs, you have the option
You will need to express it using Cron expressions
The issue is that lets say i created a file at 10 hrs in day and the cron is scheduled to run at 12 hrs, so now that file will only stay for 2 hr, and I want it to stay for 1 entire day. The also issue is that lets say file is created at 11 50 and cron will then delete at 12
You could add logic in the function to delete only files created just 24h (database things include timestamps)
So how can i get the time of file creation?
Like any other attribute but with $createdAt as attribute
Sorry but cant get you
You have a hidden attribute called $createdAt https://appwrite.io/docs/models/fileList
This attribute has the creation date, hour, etc.
So you can check with such attribute when it was created and delete if it has been created during the desired period
Got it, thanks a lot
[SOLVED] Delete file from bucket after some time
Recommended threads
- Error getting preview of file
Rest Response: ``` { "message": "Server Error", "code": 500, "type": "general_unknown", "version": "1.8.1" } ``` Appwrite Logs ``` appwrite ...
- Storage images using custom domain retur...
Some of the images uploaded to my storage bucket returns this error: ``` { "message": "Project with the requested ID could not be found. Please check the value...
- Bandwidth limit for your organization ha...
I received an alert that I exceeded the Free plan bandwidth limit (showing 5.86 GB), but my dashboard tells a different story. The usage stats there are much lo...