Technology · Files

How to store uploads outside the application process

A file that lives only in the request, or that anyone can download by changing an id, is not stored.

By OdooMatrix Published 1 min read

Part of a complete guide

This task is one section of Eight software practices that keep business apps reliable, with 7 related tasks on one page.

1. Pick a store

Put uploads on a disk or object store that survives a restart of the web process. Keep the path or object key on the record, with the owner.

2. Limit what you accept

Allow the types the feature needs and a maximum size. Reject the rest before you save.

3. Check the owner

Download as the owner and succeed. Download as another user and fail. Guessing a nearby id must not return the file.

4. Delete with the record

When the business record is removed, remove or retain the file on purpose. Do not leave customer files with no owner.

5. Frequently asked questions

Can I store files in the database?

You can for small files, but large uploads will bloat backups. Decide before the first real customer file.

Should the file name be the download name?

Show a safe display name. Do not trust the original path from the browser.

What about a public brochure?

Mark it public on purpose. Everything else stays private to the owner.

6. Related articles and next steps

How to judge it

Treat the checks below as the acceptance test for the change. Names of libraries can vary; the behavior to prove does not.

Continue learning

Need this built?

See software development or email OdooMatrix.

← Back to all articles