Deleting files and corresponding entries from database

后端 未结 5 767
情书的邮戳
情书的邮戳 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:49

    Here is one possibility.

    You could first move the file to a 'Deleted' folder, then delete the entry in the database. If that fails, restore the file from the 'Deleted' folder.

    To get rid of the files in the 'Deleted' folder, either do it right after the entry from the database is deleted. If that fails, then you end up you orphan files in a 'Deleted' folder... Depending on you requirement, this might not be a problem.

    Another option would be to have a call (maybe on SessionEnd, or a service) that would do the clean up of the database.

提交回复
热议问题