Deleting files and corresponding entries from database

后端 未结 5 809
情书的邮戳
情书的邮戳 2021-01-25 19:08

I have a web site which handles files management. User can upload file, add description, edit and delete. What are the best practices for that kind of scenario?

  1. <
5条回答
  •  死守一世寂寞
    2021-01-25 19:29

    I usually find it best to go with doing soft deletes, especially for data in the database.

    Doing it this way you could simply put the file in a new location to denote it as being deleted, and mark the entry in the database as being removed. This then allows you to still work with the file if the database delete fails for some reason.

    Once you have the file in a new location, you can either backup that location to another place or set something up to periodically delete items from that location.

提交回复
热议问题