Files and uploads
Send uploads straight to storage, resume big ones, check and scan every file, clean images, and serve private files through short-lived links.
- Required 6
- Recommended 3
- Optional 1
Required
Confirm every upload on the server
RequiredKeep a new file
pendinguntil the server has checked its size, type and checksum from the stored bytes. Never trust what the client reports.Scan files for malware before anyone opens them
RequiredScan every file that other people or systems will open, and serve it only after the scan says clean.
Rebuild every uploaded image
RequiredDecode each uploaded image, turn it upright, shrink it to a size limit and save it again as a new file without metadata. Never serve the original.
Serve private files through short-lived links
RequiredKeep the bucket private. Check access on every download request, then redirect to a signed address that expires within 5 minutes and sets safe download headers.
Delete files when their owner is deleted
RequiredRecord every stored object in a files table with its owner, and delete the objects in the same job that deletes the owner.
Neutralise formulas in spreadsheet exports
RequiredIn every CSV or spreadsheet export, prefix a single quote to cell text starting with
=,+,-,@, a tab or a carriage return.
Recommended
Upload straight to storage with a signed address
RecommendedLet clients send file bytes straight to object storage through a pre-signed address that your API issues, limited in size, type and time.
Make large uploads resumable
RecommendedLet any upload over 100 MB, or any upload from a phone, continue from the last received byte after a dropped connection.
Lay out storage by owner and let rules clean it
RecommendedName every stored object by stage, owner and a random ID, with the stage as the first prefix. Let storage lifecycle rules delete what nobody needs.
Optional
Store the same file once per owner
OptionalWhen users upload the same file often, store it once per owner under its SHA-256 hash and count the references.
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.