Parsware
All articles

Tables and data

Large files: where they go

A file too big for the environment's database is moved to object storage on its own. The form, Download and who may read it all stay the same, and deleting the record deletes the file.

A Signed document field in dark mode holding an 8.6 MB signed scan, above an audit entry showing the field changing from a recordfile reference to an objectstore one, next to the title "Large files: where they go"

In Files and pictures on a record we attached a 30 KB contract. A File field takes up to 4 MB, because the environment's database is for records rather than scans. Now we attach the signed copy, a 9 MB scanned PDF, to the same field.

We're using the Contracts — Files of Any Size sample again, from the platform's sample solutions. Every picture here is the real product.

Nothing changes on the form

Choose Replace, pick the scan, and save:

The Signed document field holding Northwind supply agreement - signed scan.pdf, 8.6 MB, with Replace, Download and Remove

It looks exactly like the 30 KB file did. There was no warning and no question about where to put it, and Download gives back the same file, byte for byte.

That's deliberate. The person attaching a contract shouldn't have to know how Parsware stores it. The platform decides, and there's no setting for it on the field, the table or the form.

Where it went

A file over the cap goes to object storage, the platform's store for large files, instead of into the environment's database. The record's file entry stays in the database, with the file's name, size and a checksum. Only the bytes move.

If auditing is on for the table, the record's history shows the move. Here is the contract's audit log, newest first:

The audit log for par_contract: row 3 shows par_document changing from empty to recordfile:9c72c7b0…; row 1 shows par_document changing from recordfile:9c72c7b0… to objectstore:records/5c3f953a…/e997c7a6…/par_contract/ceec73ac…/par_document/c412d9ad…

The first change set the field to a recordfile: reference: the small PDF, in the database. The latest set it to an objectstore: reference, and that reference is the object's address:

records/<tenant>/<environment>/par_contract/<record>/par_document/<file>

The file's bytes never appear in the audit log, only where the file is.

The tenant and the environment are part of the address. That's what makes cleaning up simple: a record's files, a table's files or a whole environment's files each sit under one prefix.

What stays the same

  • Who can read it. A large file is served through the record, under the record's permissions, exactly like a small one. There's no public link, and no link that stops working after an hour.
  • Deleting. Delete the record and its large file goes too. We deleted a second contract with a 9 MB scan, and its object was gone from the store.
  • Replacing. A new file replaces the old one, wherever either of them is kept.

Limits

  • Above the 4 MB cap, a file can be up to 512 MB. Past that it's refused with its own message: over the cap means somewhere else, over the limit means nowhere.
  • A picture is shrunk in the browser to at most 1024 pixels on its longest side, so it nearly always stays well under its 1 MB cap and stays in the database.
  • Large-file storage is part of a standard installation. Where it isn't set up, a file over the cap is refused rather than stored.

Why two places, and not one

It would be simpler to have one store for every file. Each obvious choice of one is worse, though, and the reasons explain the design.

Everything in the database keeps a file with its record: one backup, one transaction, nothing else to run. That is perfect for a 30 KB photo and wrong for a 300 MB survey. Large files make the database slow to back up and slow to restore, and every copy of the database becomes a copy of every scan anybody ever attached.

Everything in object storage is built for large files, and it handles them well. But then showing a contact's thumbnail beside their name means a second service in every list, and a photo can no longer be read in the same step as the record it belongs to.

So Parsware keeps both and lets the size decide. Most of what people attach to records, photos, signed letters and small PDFs, stays with the record. The occasional large scan goes to the store built for it. Neither the person attaching the file nor the maker who designed the table has to choose, and nothing about the field changes when the platform does.

How the reference tells the two apart

The column on the record always holds a reference that names its store:

Reference Where the bytes are
recordfile:<id> In the environment's own database, beside the record
objectstore:records/<tenant>/<environment>/<table>/<record>/<field>/<id> In object storage, under that key

That is why the audit log above could show the move so plainly. It is also why adding the second store needed no change to any table: a File column was always a reference with a scheme, so a large file is just a new scheme. Either way, the file's name, type, size and SHA-256 checksum stay in the environment's database, so describing a file never needs the store.

What happens when you press Save

For a file over the cap, the platform does the work in an order chosen so that nothing is lost whatever fails.

  1. The browser sends the file to the platform, exactly as it would a small one.
  2. The platform streams it to object storage, under the record's key, taking the checksum as the bytes go past. A 300 MB file is never held in memory all at once.
  3. Only then does it save the file's details in the database and point the record's field at the new reference.
  4. If the record had a file before, that one is removed from wherever it was.

If step 3 fails, the bytes are in the store with nothing pointing at them. That costs some disk space and nothing else: a regular orphan sweep removes objects that no record refers to, once they are old enough not to be an upload still in progress. It only ever touches keys the platform wrote, so anything else kept in the same bucket is safe.

Reading a large file

Download on the form, the record's file address in the API and getRecordFile in a script all work the same for both stores. The platform reads the file from wherever it is and streams it back.

It does not hand out a time-limited link to the store, which many systems do for large files. Such a link works for whoever holds it until it expires, so who may read this file would start to depend on how big the file is. Here the rule is always the same: you can read the file if you can read the record.

Planning for size

The numbers that matter, in one place:

Limit Size What happens past it
Image field 1 MB Shrunk in the browser first, so almost never reached
File field, kept with the record 4 MB The file goes to object storage instead
Any file on a record 512 MB The file is refused, with a message saying so

Half a gigabyte is a deliberate ceiling. It covers office documents, drawings and long scans, which is what records collect. It doesn't try to cover video archives or backups of other systems; those belong in object storage directly, through a script or an export, as Export files to object storage shows.

Deleting, at every level

A large file is removed whenever whatever made it reachable goes:

  • Replace or remove the file, and its object is deleted when the record is saved.
  • Delete the record, and every large file on it goes, because they all sit under the record's part of the key.
  • Delete a table, and the files of every record in it go the same way.
  • Delete an environment, and the platform removes that environment's whole part of the store as it tears the environment down.

Each is one delete of everything under a prefix, which is why the key carries the tenant, the environment, the table and the record. Nothing waits for a nightly job to tidy up after you.

Seeing what is stored

Administrators can see what is stored from Storage in the maker portal's Admin rail. It lists the buckets your apps and integrations use, and above them your organisation's total use, which counts files on records too, because both come out of the same allowance. A trial may store 100 MB; a paid plan sets its own figure, or none. What's in object storage walks through the screen.

Questions that come up

Can I force a small file into object storage, or a large one into the database? No. The size decides, so that the same file always ends up in the same place and nobody has to remember a rule. The cap is the same for every table.

Will a file move back to the database if I replace it with a smaller one? Yes. Each file is placed by its own size when it is saved, so replacing a 9 MB scan with a 200 KB copy puts the new file beside the record and removes the old object.

Does a large file slow the form down? Opening the record doesn't download the file; the form shows its name and size and fetches the bytes only when somebody chooses Download. A record with a large file opens as quickly as one without.

What if object storage is down when somebody saves? A file over the cap can't be stored, so the save says so and nothing is half written. Small files carry on as normal, because they never needed the store.

Can a portal visitor upload a large file? Yes, within the same limits, if the portal lets them change the record. The file goes wherever its size sends it, and it is served back only to visitors who may read the record.

For whoever runs the installation

Backups now come in two parts. A database backup holds every record and every small file, but not a large file's bytes, which are in object storage. Back up and restore the two together, or a restored database will have records whose large files are missing.

Next: a picture and a second line beside every record, so lists and lookups show who or what each record is.