Picture Uploader/File Manager Dilemma

I allow users to upload photos for two different use cases: profile pictures and photos that get posted to social media. The profile pictures are stored as an image field in a data type but the latter category are so-called “orphaned” photos (i.e., not tied to a data type or saved in the database).

I want to purge File Manager of this second category every 24 hours without deleting profile photos or my own app’s image assets (that had to be uploaded via a picture uploader and thus end up in File Manager). How can I do this without going through and deleting images one by one?

To me it sounds like you’d like to delete every photo every 24 hours. (Except for profile pictures.)

My approach would be to make a repeating group somewhere in your app, which would do a search for the pictures not tied to a user profile picture.

Once you’ve got the “Do A Search For” correct, you have the pictures you want to delete.

You can now take that “Do A Search For” Logic, and put it on the backend api, that deletes those pictures, and schedules itself to run again in 24 hours.

Hope that makes sense. :man_shrugging:

1 Like

A daily ran, recursive workflow may be what you need here however, it may be easier. If you go :unicorn: , you’ll need a new method.

1 Like

@jobs @jared.gibb both great answers and along the lines of what I was thinking, however, when I tried something like this, the uploaded files were still present in File Manager. I have to come up with a way to delete them from File Manager itself and it appears Bubble doesn’t provide that option at present.

If I was faced with this decision, I would save images is a base64 string on a database thing. Then I would delete all of the things that were created 24 hours ago or greater every 24 hours.

1 Like

If you want to delete them from Bubble storage, you can’t let them become orphaned. You must retain a reference to any file you wish to remove from Bubble storage. That was the point of the 2 yr old thread to which you replied.

1 Like