---
title: "Attachments and Files in a Business Application: Versions, Sizes and Archiving"
description: "File upload looks like a solved problem. Until somebody asks which of the five versions of the contract is the valid one, and why the database backup is 400 GB."
canonical: "https://interfase.sk/en/news/attachments-and-files-in-a-business-application-versions-sizes-and-archiving"
lang: "en"
last_updated: "2026-11-27"
---

# Attachments and Files in a Business Application: Versions, Sizes and Archiving

> File upload looks like a solved problem. Until somebody asks which of the five versions of the contract is the valid one, and why the database backup is 400 GB.

Published: 2026-11-27

- Files do not belong in the database — they belong in file storage, with the database holding a reference and metadata.
- Uploading a new version should not overwrite the old one; for documents with legal weight, doubly so.
- A size limit and a list of permitted formats are a security measure, not only an operational one.
- Access to an attachment has to be checked on every download — not only when the list is displayed.

Attachments exist in every business application and are almost never part of the brief. "Let people upload a file there" — one sentence that, two years later, means five versions of the same contract with no way of telling which one applies.

## Where files belong

The first decision, and the only one that is hard to change later: **files do not belong in the database.**

Storing a PDF directly in a database field works at ten documents and fails at ten thousand. A backup that used to take a minute takes hours, and recovery after a failure stretches from minutes to half a day.

It is done the other way round: **the file goes to file storage, the database holds a reference and metadata** — who uploaded it, when, what type it is, which record it belongs to. That brings backup and recovery back to sensible numbers; it connects to what we describe in [backup and recovery for a business application](/blog/zalohovanie-a-obnova-firemnej-aplikacie-rpo-a-rto-v-praxi).

## Versions instead of overwriting

The second most common mistake is uploading a new file over the old one. For a product photograph that is fine. For a contract, a complaint record or technical documentation it means the original state cannot be evidenced.

The correct behaviour: **a new version is added, the old one stays**, and it is obvious which one applies. The latest is displayed, the older ones remain available.

It is the same principle as with database records — do not delete, mark. We covered it in [database design](/blog/navrh-databazy-rozhodnutia-ktore-sa-vypomstia-po-dvoch-rokoch).

## Limits and formats are security too

Without a size limit, sooner or later somebody uploads a two-gigabyte video into a field meant for a photograph of damage. Without a list of permitted formats, an executable finds its way into the application.

What should apply:

- **A list of permitted types**, not a list of forbidden ones — enumerating what is allowed is the only way to keep it maintainable.
- **Checking the actual content**, not just the extension. A file named `.pdf` need not be a PDF.
- **A sensible size limit** for each attachment type separately.
- **Virus scanning** on upload, if the files get forwarded or opened by other users.

## Permissions are checked on download

This is the most common security hole in handling attachments. The application correctly shows only the attachments a user may see — but the file link itself works for anyone who knows it.

All it takes is for somebody to forward the link and a salary statement leaves the company. Access therefore has to pass a check **on every download**, and for sensitive documents the download is logged — a principle we describe in [access audits](/blog/audit-pristupov-a-bezpecnostne-logy-vo-firemnej-aplikacii).

## Scanned PDFs and search

A document that is an image with no text layer is stored in the application but nothing can be found in it. At archive scale that is the difference between usable and unusable.

The answer is converting scans to text on upload, not retroactively. Catching up on ten thousand documents is a project; processing them as they arrive is a feature.

## An archive needs a rule, not a disk

Files accumulate and never diminish until somebody decides otherwise. So each attachment type carries **a retention period** — how long it stays available in the application, when it moves to cheaper archive storage and when it gets deleted.

For documents with personal data that is not a choice but an obligation. And "we will keep it there forever" is also a decision — it is just one nobody knows they made.

## Where to start

With two questions about your existing application: **do attachments get overwritten**, and **can a file be downloaded through a direct link without logging in?** The first determines whether you can evidence history; the second is a security question and the answer tends to be unwelcome.

If you are building an application or dealing with an existing one, [get in touch](/kontakt). We handle it as part of [custom development](/riesenia/vyvoj) — examples in our [case studies](/referencie).


---

Web version: https://interfase.sk/en/news/attachments-and-files-in-a-business-application-versions-sizes-and-archiving
llms.txt: https://interfase.sk/llms.txt
