i am uploading images and stuff to my storage. but is there a system that i can follow to delete the

i am uploading images and stuff to my storage. but is there a system that i can follow to delete the stored object if its related party is deleted on the mongodb? like i am uploading an image to r2 & then using the url for the image in the document as a header whoes object is stored in mongo. if that document is deleted in mongo, how do i delete the image in r2? like any guidance?
Was this page helpful?