I have an entry with field of type media.
When I'm trying to delete some entry, I'm using code:
strapi.query('entry').delete({ id: entry.id });
strapi.query('file', 'upload').delete({ id: entry.image.id });
The entry is deleted successfully, as well as record from "Files Upload". But file still stays in upload folder. How can I delete it?
This code removes entry from Media Library and deletes files from uploads
directory:
const file = await strapi.plugins['upload'].services.upload.fetch({ id });
await strapi.plugins['upload'].services.upload.remove(file);