DataData ModelSections
Data Model Designed
What the service keeps, how the pieces relate, and what every field means. The SQL is on the Schema tab.
Entities
File
A file a user stored, and what Upload knows about it.
Belongs to one user, by owner_id only. Other services refer to it by file_id. Its content is one object in the S3 bucket.
upload.files
Stored object
The file's bytes, in a private bucket.
Exactly one per file that is not rejected or deleted, at the file's s3_key.
(S3, not the database)
Processed event
A platform event Upload has already acted on.
Stands alone. Holds the event's ID only, not its contents.
upload.inbound_events
Audit event
A permanent record that something happened to a file.
Refers to the file and the user by ID, with no foreign key, so the record outlives a deleted file.
upload.audit_events
Life of each record
- File
- Created as `pending_upload` → after the check, `ready` or `rejected` → `deleted` when the user or their account deletion removes it, or `expired` after 30 days. A `pending_upload` file left for 24 hours is deleted by the daily clean-up. A file never returns to an earlier status.
- Stored object
- Arrives when the browser sends it → removed at once if the check rejects it, when the file is deleted, or by the bucket after 30 days.
- Upload and download links
- Never stored. Signed on request and valid for 5 minutes.
Fields
upload.files
One row per file. Created when an upload is requested; it never stores the file's content, only where it is and what Upload knows about it.
iduuid- The file's ID everywhere in 01scale. Other services store it as
file_id. - Primary key. UUIDv7, generated by the service
owner_iduuid- The user who owns the file: the
subof the caller's access token. An app storing a file for a user (DocFlow's results) uses a delegated token for that user. A plain ID: Identity's tables are not reachable from here. s3_keytext- Where the object lives in the bucket. Built from IDs only, so a file name can never change the path.
- Unique. Always
users/{owner_id}/{id}/original.{ext} file_nametext- The name the person gave the file, shown in the UI and used for downloads. 255 is the longest file name most file systems allow.
- 1 to 255 characters, no
/,\or control characters mimetext- The file's type, as declared and then confirmed from its first bytes.
- One of
application/pdf,image/png,image/jpeg,application/json,text/csv size_bytesbigint- The declared size, which the upload link enforces. 10 MB keeps a single extraction within the time limits of a serverless function.
- 1 to 10,485,760
pagesintegercan be empty- Set when the upload is checked. Empty until then.
- 1 to 10 for a PDF; 1 for an image; empty for JSON and CSV
acceptjsonbdefault '{}'- The calling app's limits at the time of upload, kept so the check on completion applies the same rules.
- Only the keys
mimes,max_bytes,max_pages statustextdefault 'pending_upload'- Where the file is in its life (see below).
- One of
pending_upload,ready,rejected,deleted,expired rejection_reasontextcan be empty- Why the check failed, for a plain-language message.
- One of
type_mismatch,too_many_pages,unreadable,size_mismatch; set exactly when status isrejected sha256textcan be empty- A fingerprint of the content, to prove later that the file was not changed and to spot the same file uploaded twice.
- 64 lower-case hex characters; set exactly when the file has been
ready created_attimestamptzdefault now()- When the upload was requested.
completed_attimestamptzcan be empty- When the check ran.
- Not earlier than
created_at deleted_attimestamptzcan be empty- When the file was deleted.
- Set exactly when status is
deleted expires_attimestamptz- When the bucket's lifecycle rule removes the object. Shown to the person so it is not a surprise.
- 30 days after
created_at
upload.inbound_events
One row per platform event Upload has acted on, so a repeated delivery has no effect.
event_iduuid- The event's ID, from the sender.
- Primary key
typetext- What happened, for example
identity.user.deleted. - 1 to 100 characters
created_attimestamptzdefault now()- When Upload processed it.
The service template also gives Upload audit_events, idempotency_keys and outbound_events. Upload writes file.created, file.uploaded, file.rejected, file.downloaded and file.deleted to audit_events, uses idempotency_keys for POST /files, and keeps inbound_events (above) so a repeated event has no effect. In version 1 it announces no events of its own.
Data model level: business rules the service guarantees
- A file is usable (can be downloaded or extracted) only when its status is
ready. - A file is
readyonly after its stored size matches the declared size and its first bytes match its type. - A rejected file has no stored object: it is deleted in the same step that rejects it.
- The storage key is built from IDs only, never from the file name.
- One file belongs to exactly one user and is never shared or moved to another.
- Deleting a user's account deletes all their objects and marks all their files
deleted. Rows are kept, without content, so audit records still make sense. - A status only moves forward:
pending_upload→readyorrejected→deletedorexpired. - Every change of status writes an audit event in the same transaction.
What is deliberately not stored
- The file's content: it lives only in S3, never in the database.
- Upload and download links: signed on request, valid for 5 minutes.
- The original path on the person's device: only the file name.
- Anything read from inside the file except its page count: what a document says is Extraction's job, not Upload's.