Files and uploads Required
Delete files when their owner is deleted
Record every stored object in a files table with its owner, and delete the objects in the same job that deletes the owner.
How to do it
Make the delete job remove objects first, then rows, so a crash leaves rows to retry rather than unknown objects. On versioned buckets delete every version, or the file lives on. Include derived files, such as thumbnails and rebuilt images. Run a weekly sweep that lists the bucket and compares it with the table. Delete objects with no row that are older than 7 days. The request side, time limits and backups are in let people see and delete their data.
How to check
Create a test owner with an upload, a thumbnail and two versions of a file. Delete the owner. A listing of the owner's prefix, including old versions, is empty. The weekly sweep reports zero objects without a row.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers api design playbook: https://agentwranglers.se/playbook/api-design/files-and-uploads/delete-files-with-owner.