Spanish Total.js
English
Documentation For AI agents
Contents

Index files in PostgreSQL

Keep a table of all uploaded files in PostgreSQL in addition to the files on disk.

.md GitHub
On this page

OpenFiles always keeps the files on disk. If you also connect a PostgreSQL database, it writes a row for every upload into a table, and List of files reads the list from that table. Use it when you want to query your files with SQL.

Connect a database

1. Create an empty PostgreSQL database for OpenFiles.

2. In the OpenFiles folder, install the PostgreSQL driver:

npm install querybuilderpg

3. Add the connection to the config file:

database              : postgres://user:password@localhost:5432/openfiles

4. Restart OpenFiles.

On start, OpenFiles creates the table tbl_file if it does not exist.

What changes

  • Every upload adds a row with the file ID, storage (db), name, extension, type, size, width, height, upload date and the name of the token that uploaded it (createdby).
  • Renaming and removing a file in List of files also changes or deletes its row.
  • List of files shows only the files in the table. Files uploaded before you connected the database stay on disk and keep their links, but they do not appear in the list.

To go back, remove the database line and restart OpenFiles.

Made in Europe