Best practice/advice for handling file uploads related to a table/data object

This is a common scenario, and I see bits and pieces in various support topics, but no recipee or proper walkthrough.

How would you go about handling the file upload related to a simple news table, with three fields:

  • Title
  • Text
  • Image

What I am most curious about solving are problems related to:

  • naming files/images - or: how to prevent duplicates and overwriting one file with another. Do you just generate new names using UUIDs?
  • what do you do if a new record is being created, an image uploaded, but the record is not saved?
  • how do you handle deletion of images related to deletion of records?

Would love to hear from more experienced developers how you go about this… :slight_smile: