Private files
Files a trusted module keeps for itself, such as the shop's invoices: where they live, how they are checked and how they are tested. SHADE keeps them in Postgres and never serves them; the module sends one to whoever may see it from its own route.
Why Postgres
Postgres was chosen over the media drivers that were first planned for this. What the media drivers hold is
served: the local /uploads folder serves PDFs, and an S3 bucket behind media is publicly readable, so a private file
there would be one guessed address away from anyone. In Postgres a file is never served, is saved in the transaction of
the change it belongs to (an invoice exactly when its order is paid), is in every backup, and needs no setting of its
own. Large files (video) would need the drivers back, with a private bucket, when a module needs them.
Rules
- A file is at most 25 MB (
PLUGIN_FILE_MAX_BYTES); a module's files together at most itsfilescapability'smaxBytes(at most 1 GB: enough for small files such as invoices, shipping labels, UBL and signatures; every byte is in the database and in each backup). The total is checked under a lock per module, so writes at the same moment can't pass it. Replacing a file counts its new size only, and keeps when it was first written. - A key is 1 to 200 letters, digits and
._-/, without empty,.or..parts (invoices/2026-0001.pdf); a content type istype/subtype. - Only from the context SHADE gave the module's code (FORBIDDEN for core's own contexts), with the capability
(
requireCapability): a module reaches only its own files. - Purged by the capability's
data.retentionkind, by when each file was first written, in retention's own purge (registerCapabilityPurge, hourly on the worker) and counted by its preview. Files are never kept per user: the capability refusespersonal: 'user'. A file about a person (personal: 'person') is found through the module's own personal data part: a source namedfiles. - Uninstalling the module backs its files up (each body as base64) and deletes them.
Where it is in the code, and its tests: shade/features/files/README.md in the shade repository.