Hey there database mages!
I’ve got a fairly simple question that I wasn’t able to find the answer for so far.
What is the best way to delete unwanted profile picture files when the only image uploader is set to autobind user profile pictures?
So if users changing their profile image with autobinding, I only want to keep the latest image file and delete the previous one, so I don’t ending up storing 5-10 extra images when there’s only one allowed to be used at-a-time.
It must be a simple solution but I cannot get my head around it.
Thanks in advance!
You can use a When PictureUploader value is changed
action to delete the previous picture. Though, the autobinding action might be faster than the Delete an updated file
action, and you’ll end up deleting the recently autobound picture.
In that case I’d try with an extra field in the User dataype that contains the URL of the current picture. Then use the When PictureUploader value is changed
action to delete the associated file and update the field with the rencently uploaded picture.
Yes, you’re right, autobinding is quicker and that’s the core issue. My problem is: how could I validate the right file?
Perhaps I can do a search for image that is assigned with the current user and is not their current profile image, and delete that. That actually might just work.
Thanks for thinking about it with me, this was genuinely helpful!
Well… I have no idea how I search for files in the DB lol 
What I was thinking also is to save the current image into a different place like “deleted profile picture” in the user table, but I came across the same issue again: autobinding is quicker.
So I guess it is pointless to use autobinding and do a When pictureUploader value is changed
step by step workflow instead. It is way cleaner and more managable. I can basically replicate the entire autobinding feature with my own automation this way.
I guess AB is doing the same thing in the background anyway.
Yep, I think that would be the best option 
1 Like
Yes, it worked like a charm.
Solution in short: forget about autobinding for files when you don’t have a manual delete your file
button available to your users.
What I’ve done in this workflow is to delete the current profile image file first then replace it with the uplader’s current file.