Skip to main content
Premium

S3 temporary file cleanup

Chunked uploads land under a temporary prefix first; what removes them afterwards is S3's own lifecycle policy, not the application.

How a file leaves the temp prefix​

SituationWhat removes the object
The record is savedThe file is server-side copied to its final key; the temp original is left to the lifecycle rule
The user cancelsThe abort endpoint deletes the object and cancels the multipart upload
The form is abandonedNothing — the object stays until the lifecycle rule expires it

Required lifecycle rules​

Two rules on the bucket:

  1. Expire objects under tmp_prefix after a short period — one day is enough, since a file that has not been saved by then never will be.
  2. Abort incomplete multipart uploads after the same period, otherwise their parts are stored and billed without ever appearing as an object.
caution

Without these rules abandoned uploads accumulate silently: they are not visible as records, and incomplete multipart parts are not visible in the bucket listing at all.

See also​