Not necessarily, but that might be the easiest way to go about it. Conceptually speaking, by “flag”, I simply mean there needs to be some way to “filter” uploaded files that you wish not to keep. It’s entirely up to you as to how that’s implemented. What’s key is that any file that you do wish to keep must not show up when the “flagged” search constraints are applied.
As outlined in a prior post, implementing a global “Garbage Collection” list is one approach. Just make sure files you do wish to keep do not appear in that list.
For example, let’s say you have a user profile page which allows a user to save information about themself, including a single profile image. A user might change their mind and have uploaded several photos before saving their profile. Each uploaded image could be added to the garbage collection list immediately upon upload. Then, when the profile is actually saved, the currently selected photo would be removed from that list.
I hope that makes sense. (Unfortunately, I don’t currently have an example to which I can provide edit access.)
EDIT: And if you’re dealing with images and wish to conserve your Bubble storage, you might take a look at Upload Buddy. It allows you to scale images before upload, thereby, saving bandwidth, user time, and Bubble storage.
Yes that makes sense. I just need to figure out how to make this scale as I need to add files to different data types and need to figure out the architecture.
I’m also fighting against using the simple file uploader or the multi file uploader. They both have their pros and cons.
I prefer the multi file uploader for the end user experience but I’m struggling to save the log on “input value change”.
Thanks again, I think with your help, now I just need to tie everything together.
I’ve managed to pull it together and it’s working, thanks to you. It really is great.
I just have one more question as it looks like you’ve already been through this. What is the best practice or what do you recommend I do with the “Garbage Collection” log? I use it to delete the files that the user doesn’t end up using when the user saves the form, but what do you recommend is the best practice to clean (delete) the log or of file urls that have now been deleted?
I just realised I have to also prepare this solution to handle when a user comes back and uploads a different file again. I have to flag the file for garbage, that originally was ok.
All I know is that File handling in Bubble is a topic that can be greatly improved. It’s not there yet, we have to do a lot of work for privacy issues, making sure files are not orphaned.
@sudsy Did your solution actually delete the uploaded files from File Manager? When I delete an uploaded file (orphaned or not), the file still resides in File Manager until I delete it within File Manager specifically. Am I missing something?
If you remove a file from Bubble storage using the Delete an uploaded file action and then go the File Manager and click the Search button to refresh the file list, the file should not be there.
I had the same problem and my solution was to schedule a garbage collector after the file is created.
In my case, i’m creating files in a Server Side Action and then scheduling a custom API workflow to delete that file
Also, there is an interesting thing about ‘Attach to’ field, it can be filled aparently with any content, so a possible solution could be looking for files where ‘attached to’ contains x value, but i don’t think that lookup is possible right now