Apostrophe CMS Main Site Forum Home

Deleting from Trash



I am fully aware of how to enable purging elements from the trash under ‘Pages/Reorganize’…However, I am struggling to find any documentation that allows you to purge from the trash for other ‘pieces’ like Files or Images…or even custom pieces.

Is there a quick way to enable this feature?



I believe you are looking for deleteFromTrash - docs


Hey, thanks for the reply. I could be wrong, but that seems to only be fore the apostrophe-pages module…aka you can only delete pages from the trash. I am looking for a simple way to delete images/files/pieces permanently from the system.


There is currently not a complete implementation of this feature. It is not something our clients so far have made a firm requirement, and it is of course a very risky feature to give your customer. I can see a use case for it when you’re moving from pre-launch to launch and want to get rid of a lot of sloppy early efforts. Of course there are sometimes legal requirements too.

This feature would make a great enterprise support project if you’re interested in supporting its development. Feel free to reach out to support@punkave.com.


I always wondered why deleteFromTrash was a flag that needs to be set to true. I just bumped into the need to start deleting content from my dev deploy.

Considering that at some point I will release control of the backend to my client’s content manager, it feels like a limitation to not allow them to purge or individually delete from the images/files repository.

In this scenario, it makes sense to only allow admins to do this, but a complete no-can-do?


It’s not a complete no-can-do, it’s a feature that hasn’t been a priority so far for our clients, and so not something we’ve had a chance to pursue on our end. Feel free to contribute though, or to engage us to add the feature to apostrophe as an enterprise support project.


This is the first time I use Apostrophe for a client project in replacement of any other CMS solutions. This is my test drive, so I would say the Enterprise solution (which sounds like paying for a feature) is out of the question; at least for me.

Contributing might be an option.

Would it be safe to assume that the logic for deleting a file is the same used for deleting a page?

Can you point me to the right starting point to implement this feature for all attachment repositories (images, files, etc) ?


FYI, most of the time enterprise clients are paying for a feature to be added to open source Apostrophe, for the benefit of everyone. It is a model that works well for everyone because typically they don’t want to “own” or have sole responsibility for a CMS (not even as the sole customer), but have the resources to make that solution better for themselves and others.

So, to answer your question: thanks for looking into making this contribution! Here are the challenges.

For docs (the apos.docs.db mongodb collection), it’s easy. If it has the trash property, you remove it from mongodb. The end.

For attachments, i.e. your uploads, it is a little trickier. These are in the apos.attachments.db collection. If they have the trash flag, you want to remove that item from the collection, but only after using uploadfs to remove it from storage. Note that rm-ing it from public/uploads/attachments will not cut it, you need to use the uploadfs APIs properly and remove all cropped and scaled versions as well. There is some code for this in the apostrophe-multisite module, which does something similar when copying a site.