Skip to content

Managing Orphaned Upload Files

Published: at 07:12 AM

Managing Orphaned Upload Files

When handling file uploads in an e-commerce system, orphaned files can accumulate and consume storage space.

This is what I figured: When customers upload the files, they get saved to the database. They might not continue with the order because they uploaded the wrong file, left their order for later or just abandoned it or some other reason. Those uploaded files are never linked to any orders. So, all files which are linked to the orders can get deleted but the rest stay put, untracked, consuming storage space.

Implementation Approaches

  1. Delete all files older than ‘n’ days: Files of orders older than n days can be deleted. So instead, we can simply delete all files older than n days.

  2. Delete files with no order: What I ended up implementing is for all files linked to an order, move them to a new folder. Then, I can simply run a regular maintenance task to delete all files in the default user uploads folder.


Previous Post
Understanding GSM vs Non-GSM Characters
Next Post
C#'s Hidden Gems and Modern Features