I’ve recently discovered that I have many (30,000+) images that were being saved to file manager that have now been orphaned. Is there a way for me to traverse the file manager entries so that I can check if each entry has a reference in my database and if not, delete it? I can’t see any way to access file manager url’s directly from workflow.
Can you check the Optimization option in bubble setting, see if it can give you a way to delete orpand file.
one more thing, i learn that , when a file is not link to a thing, bubble will automatically delete it, i don’t know how much true it is.
@mikeloc can you help us here sir.
Thanks for your response. Bubble does not seem to be removing these files at all. I’m certain they aren’t being reference anywhere from our database. I did not see any thing in optimize to do this - When I click on Optimize application, it just seems to give me page elements and workflows that are not being used, nothing to do with file manager entries.
The only way (currently to my knowledge) available to take care of deleting orphaned files in file manager is to manually delete them.
A lot of developers usually create a custom ‘File’ data type to take care of this issue.
There are a lot of posts on forum which can help you understand more. You can start here. [SOLVED] Preventing "orphaned" files - How would you handle it?
I didn’t know that. Is it mentioned in manual?
That is absolutely not true. File storage must be managed by the Bubble dev.
Also, it might be helpful to understand how images, in particular, are handled by Bubble. You can check out this post for an overview; but basically, Bubble automatically optimizes served images via an external service called Imgix. It’s not actually the uploaded image residing in Bubble storage that’s served on a Bubble page, but rather a web-optimized version of it.
And while the cost of Bubble file storage has decreased dramatically since this old post was written, it’s still a good general practice to optimize Bubble file storage by keeping the size of uploaded images down and implementing the appropriate logic to reduce or eliminate orphaned files.
EDIT
Just wanted to note that there’s a way, via a query string parameter, to bypass the Imgix optimization, but generally speaking for most use cases, it’s not necessary or recommended.
Thanks for the info. I’ll definitely be making a fix to prevent the orphaned files in the first place, but I’m still uncertain how I can go about removing the 30000 plus images that are already orphaned. I suppose I could write a backend workflow that deletes them all and reuploads the ones I’m actually using?
I suppose I could write a backend workflow that deletes them all and reuploads the ones I’m actually using?
If the files are truly orphaned, then there would be no reference to them in the DB, so I don’t think that would work.
I’m not sure how to go about mass deletion of orphaned files. If you don’t have to be selective about it - i.e. you just want to nuke all of them - there might be a way to create an automated browser process using something like Chrome’s “Recorder” feature. Maybe someone else has another idea.
It looks like if I don’t have to be selective about it I can do it manually from file manager, but there are a few thousand of them that are actually being used. The only thing I can think of is to migrate the ones I use to a different app that I build for this purpose, and then go back and transfer them back after I nuke them manually. I was hoping that I could find a better solution.