--- title: Introduction project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/introduction/ updated: 2026-11-19T07:45:42.832Z --- # Introduction > What OpenFiles is, what it does and where to start. OpenFiles is a small file server for your other apps. Your apps upload files to it through a REST API, and OpenFiles gives each file a permanent link that anyone can open. You manage everything in a web interface: the storages that hold the files, the API tokens your apps use, and a few settings. OpenFiles is an official Total.js app under the MIT license. The code is on [GitHub](https://github.com/totaljs/openfiles). ## What you can do - Keep files in separate **storages**, for example `photos` and `documents`. - Let each app upload with its own **API token**, limited to the storages you choose. - Upload files as `multipart/form-data` or as Base64 JSON. - Share every file through a public link, or as a download. - Browse, filter, sort, rename and remove files in the web interface. - Keep a searchable index of the files in PostgreSQL if you want one. ## How it fits together 1. You create a storage, for example `photos`. 2. You create an API token for your app and allow it to upload to `photos`. 3. Your app sends a file to `/upload/photos/` with the token. 4. OpenFiles answers with the file ID and its link, for example `/files/photos/JapO3b1e961f-pn.png`. Your app saves that link and shows it to its users. ## Where to go next - Install OpenFiles [from source](../install-source/) or [with Docker](../install-docker/). - Sign in for the first time: [First sign-in](../first-sign-in/). - Create your first [storage](../storages/) and [API token](../api-tokens/). - Connect your app: [REST API overview](../../reference/rest-api/). --- title: Install from source project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/install-source/ updated: 2026-11-19T07:45:42.832Z --- # Install from source > Install OpenFiles with Node.js and start it on your computer or server. You need [Node.js](https://nodejs.org) (a current LTS release) and Git. ## Install and start **1.** Get the code and open its folder: ```bash git clone https://github.com/totaljs/openfiles.git cd openfiles ``` **2.** Install the dependencies (once): ```bash npm install ``` **3.** Start OpenFiles: ```bash npm start ``` **4.** Open `http://localhost:8000/` in your browser and sign in. See [First sign-in](../first-sign-in/). OpenFiles keeps running until you stop it with Ctrl+C in the terminal. ## Use another port `npm start` uses port 8000. To use another port, start OpenFiles with Node.js and pass the port: ```bash node index.js 8080 ``` ## Where your data is saved Files, tokens, settings and the admin account are saved in the `databases` folder inside the OpenFiles folder. See [The data folder](../../reference/data-folder/) and [Back up your data](../backups/). Before you open OpenFiles to other people, read [Run in production](../production/). --- title: Install with Docker project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/install-docker/ updated: 2026-11-19T07:45:42.832Z --- # Install with Docker > Build a Docker image from the OpenFiles code and run it with your data in a volume. The repository has a `Dockerfile`. You build the image yourself and run it with a volume, so your data survives when you recreate the container. ## Build and run **1.** Get the code and open its folder: ```bash git clone https://github.com/totaljs/openfiles.git cd openfiles ``` **2.** Build the image: ```bash docker build -t openfiles . ``` **3.** Start a container. OpenFiles listens on port 8000 inside the container, and the volume `openfiles` keeps the data: ```bash docker run -d --name openfiles -p 8000:8000 -v openfiles:/www openfiles ``` **4.** Open `http://localhost:8000/`. The sign-in page shows the first-start account. See [First sign-in](../first-sign-in/). ## Where the data lives Inside the container the app runs from `/www/.src/`, and the data is in `/www/.src/databases/`. Both are inside the `openfiles` volume. When you remove the container and start a new one with the same volume, your storages, files, API tokens and account are still there. To see what is in the data folder: ```bash docker exec openfiles ls /www/.src/databases ``` See [The data folder](../../reference/data-folder/). ## Stop and start ```bash docker stop openfiles docker start openfiles ``` Before you open OpenFiles to other people, read [Run in production](../production/). --- title: First sign-in project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/first-sign-in/ updated: 2026-11-19T07:45:42.832Z --- # First sign-in > Sign in with the first-start account and replace it with your own credentials. On its first start, OpenFiles creates one admin account with a random user name and a random password. You sign in with it and then change it. ## Sign in **1.** Open OpenFiles in your browser, for example `http://localhost:8000/`. **2.** Until the first sign-in, the sign-in page shows a **Default account** box with the **User name** and **Password**. Select **Fill in the form** to copy them into the form. **3.** Select **Sign in**. After the first sign-in the **Default account** box is gone for good. The page then only shows the form: ![The OpenFiles sign-in form](/files/JapUNo2Cj61f.webp) Your session lasts one month in that browser. ## Change the first credentials Anyone who opens the sign-in page before you can read the first-start password. Change it right away: open the account menu at the top right, select **Change credentials** and set your own name, login and password. See [Your account](../account/). ## What you see next After you sign in, OpenFiles opens **File Storage**. The menu on the left has three pages: - **File Storage**: your [storages](../storages/) and their [files](../browse-files/). - **API Tokens**: the [tokens](../api-tokens/) your apps use to upload. - **Settings**: the [app name](../settings/). If you lose the password, see [Sign-in questions](../../faq/sign-in/). --- title: Storages project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/storages/ updated: 2026-11-19T07:45:44.888Z --- # Storages > Create a storage for a group of files and drop a storage you no longer need. A storage is a named folder of files, for example `photos` or `documents`. Each file belongs to one storage, the storage name is part of every file link, and API tokens get permission per storage. **File Storage** shows one card per storage: ![File Storage with the storages documents and photos](/files/JapUO52Vj60f.webp) ## Create a storage **1.** Open **File Storage** and select **Create** at the top right. **2.** Type a name and select **OK**. ![The Storage name dialog](/files/JapUO72Wj61f.webp) **3.** OpenFiles turns the name into lowercase letters and digits only: spaces, hyphens and accents are removed. It shows the final name. Select **Confirm** to create the storage. ![The confirmation with the final storage name invoices2026](/files/JapUO82Xj60f.webp) Choose a short name: your apps use it in every upload address, for example `/upload/photos/`. ## Open a storage Select a storage card to open its files. See [Browse files](../browse-files/). ## Drop a storage Dropping a storage deletes it with all its files. Links to those files stop working, and you cannot undo it. **1.** Select the red remove icon on the storage card. **2.** Confirm with **Remove**. Select **Refresh** to load the list again after your apps create files. --- title: Browse files project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/browse-files/ updated: 2026-11-19T07:45:42.533Z --- # Browse files > Open a storage, find files with filters and sorting, and open or share a file. Select a storage card in **File Storage** to open **List of files**. It shows the files of that storage, newest first. ![List of files in the photos storage](/files/JapUNl29j60f.webp) | Column | What it shows | |---|---| | **Name** | The file name. | | **Dimension** | Width x height in pixels, for images. | | **Size** | The file size. | | **Uploaded** | The date and time of the upload. | | **Options** | **Show**, rename and remove. | ## Find files - Type in the **Filter** field under **Name** to narrow the list. For example, `forest` keeps the files whose name contains "forest". - Select a column header with arrows (**Name**, **Size**, **Uploaded**) to sort by it. Select it again to reverse the order. - Long lists are split into pages. Use the arrows at the bottom to move between them. Select **Refresh** to load files your apps uploaded while the list was open. ## Open a file Select **Show** to open the file in a new browser tab. The address of that tab is the public link of the file: you can share it, and anyone who has it can open the file without signing in. See [File links](../../reference/file-links/). To change or delete files, see [Rename and remove files](../rename-remove-files/). Files reach a storage through the REST API. See [Upload files](../../reference/upload/). --- title: Rename and remove files project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/rename-remove-files/ updated: 2026-11-19T07:45:43.914Z --- # Rename and remove files > Change the name of a file or delete it from a storage. You rename and remove files in **List of files**, with the buttons in the **Options** column. ## Rename a file **1.** Select the pencil button of the file. **2.** Type the new name and select **OK**. ![The Rename file dialog](/files/JapUNz2Pj60f.webp) The new name is what people get when they download the file. The link of the file does not change, so the apps that use it keep working. ## Remove a file **1.** Select the red remove button of the file. **2.** Confirm with **Remove**. The file is deleted and its link answers `404`. You cannot undo it. To delete a whole storage with all its files, see [Storages](../storages/). --- title: API tokens project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/api-tokens/ updated: 2026-11-19T07:45:42.017Z --- # API tokens > Create a token for each app that uploads files, copy it, edit it and remove it. Your apps upload files with an API token. Create one token per app, so you can see which app uses OpenFiles and remove one app's access without touching the others. **API Tokens** shows one card per token, with the time it was last used and its summary: ![API Tokens with the token Demo website](/files/JapUNc22j61f.webp) ## Create a token **1.** Open **API Tokens** and select **Create**. **2.** Fill in the form: - **App name**: the app that will use the token, for example `Demo website`. - **Permissions**: what the token may do. For uploads, choose **Upload files** and the storages it may upload to. See [Token permissions](../token-permissions/). - **Summary**: a note for you, for example who runs the app. **3.** Select **SUBMIT**. ## Copy a token Open the token again (select its card). The form now starts with the token, hidden as `******`: ![The Update API token form with Copy token and Show token](/files/JapUNe23j60f.webp) - **Show token** shows it on the screen. - **Copy token** copies an upload address with the token to the clipboard, in this form: ```text http://localhost:8000/upload/{db}/?token=YOUR_TOKEN ``` Replace `{db}` with the storage name before you use it. The menu **...** on a token card has the same **Copy token**, plus **Edit** and **Remove**: ![The token menu with Copy token, Edit and Remove](/files/JapUNg24j61f.webp) Keep tokens secret. Anyone who has a token can upload with its permissions. ## Edit a token Select the card (or **Edit** in its menu), change the fields and select **SUBMIT**. The token itself stays the same, so the app keeps working with the new permissions. ## Remove a token Select **Remove** in the token menu and confirm. Then create a new token if the app still needs access. To call the API with a token, see [REST API overview](../../reference/rest-api/). --- title: Token permissions project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/token-permissions/ updated: 2026-11-19T07:45:44.888Z --- # Token permissions > Which permissions a token can have and which combination an upload needs. The **Permissions** field of a token has two kinds of entries: | Entry | Colour | Meaning | |---|---|---| | **Upload files** | red | The token may upload. | | **Remove files** | red | Not used by the upload API. | | A storage name, for example **photos** | blue | The storage the token may work with. | Every storage you create appears in the list as a blue entry. ## What an upload needs To upload to a storage, a token needs **both**: - **Upload files**, and - the name of that storage. For example, a token with **Upload files** and **photos** can upload to `/upload/photos/`. The same token gets `Not allowed` when it tries `/upload/documents/`. | Permissions | `/upload/photos/` | `/upload/documents/` | |---|---|---| | **Upload files**, **photos** | allowed | `Not allowed` | | **Upload files**, **photos**, **documents** | allowed | allowed | | **photos** only | `Not allowed` | `Not allowed` | ## Good practice - Give each app only the storages it needs. - Use a separate token for a web page that uploads directly from the browser, because its visitors can read the token. See [Upload from a web page](../../recipes/upload-from-browser/). See [Errors and limits](../../reference/errors/) for the answers your app gets. --- title: Your account project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/account/ updated: 2026-11-19T07:45:41.330Z --- # Your account > Change your name, login and password, and sign out. OpenFiles has one admin account. Its menu is the round button at the top right of every page: ![The account menu with Change credentials and Logout](/files/JapUNX1yj61f.webp) ## Change credentials **1.** Open the account menu and select **Change credentials**. **2.** Change the fields: - **Name**: the name OpenFiles shows for you. - **Login**: the user name you sign in with. - **Password**: a new password. Leave it empty to keep the current one. ![The Change credentials form](/files/JapUNZ1zj60f.webp) **3.** Select **SUBMIT**. If you changed the **Login**, all other open sessions are closed and your own session stays open. ## Sign out Open the account menu and select **Logout**. You see the sign-in page again. If you forget your password, see [Sign-in questions](../../faq/sign-in/). --- title: Settings project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/settings/ updated: 2026-11-19T07:45:44.228Z --- # Settings > Change the name OpenFiles shows in the header and in the browser tab. Open **Settings** in the left menu. ![The Settings page with App name](/files/JapUO22Sj61f.webp) ## App name **App name** is the name at the top left of every page and in the browser tab. Type a new name and select **SUBMIT**. You see "Settings have been saved successfully." and the new name is used at once and after a restart. The name you save here replaces the `name` in the [config file](../../reference/config/). --- title: Index files in PostgreSQL project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/postgresql/ updated: 2026-11-19T07:45:42.832Z --- # Index files in PostgreSQL > Keep a table of all uploaded files in PostgreSQL in addition to the files on disk. 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: ```bash npm install querybuilderpg ``` **3.** Add the connection to the `config` file: ```text 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](../browse-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. --- title: Back up your data project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/backups/ updated: 2026-11-19T07:45:42.017Z --- # Back up your data > Which folder to copy so you can restore files, tokens, settings and the account. Everything OpenFiles keeps is in one folder: `databases` inside the OpenFiles folder (`/www/.src/databases` in Docker). See [The data folder](../../reference/data-folder/). ## Make a backup **1.** Stop OpenFiles, so no upload is half written. **2.** Copy the whole `databases` folder: ```bash tar -czf openfiles-backup.tar.gz databases ``` **3.** Start OpenFiles again. With Docker, copy the folder out of the container: ```bash docker cp openfiles:/www/.src/databases ./openfiles-databases ``` ## Restore Stop OpenFiles, replace the `databases` folder with the copy and start OpenFiles. Your storages, files, links, API tokens, settings and account are back. If you index files in [PostgreSQL](../postgresql/), back up that database at the same time. --- title: Run in production project: OpenFiles version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/guides/production/ updated: 2026-11-19T07:45:42.832Z --- # Run in production > Settings and habits that keep an OpenFiles server safe. OpenFiles serves files to the public and accepts uploads from your apps, so the server needs some care before others can reach it. ## Change the first-start account Sign in and change the user name and password at once. See [Your account](../account/). ## Use HTTPS Tokens travel in every upload. Put OpenFiles behind a reverse proxy (for example Nginx or Caddy) that serves HTTPS, and let your apps use the `https://` address only. ## Listen only on the local address By default OpenFiles listens on all network interfaces. When a reverse proxy runs on the same server, make OpenFiles listen only on `127.0.0.1`. In `index.js`, change the line ```js // options.ip = '127.0.0.1'; ``` to ```js options.ip = '127.0.0.1'; ``` and restart OpenFiles. With Docker, publish the port only on the local address instead: ```bash docker run -d --name openfiles -p 127.0.0.1:8000:8000 -v openfiles:/www openfiles ``` ## Start in release mode `npm start` runs in debug mode. On a server, start OpenFiles in release mode: ```bash node index.js 8000 --release ``` ## Limit what tokens can do Give each app its own token with only the storages it needs. See [Token permissions](../token-permissions/). ## Restrict the admin interface The admin interface and the upload API share the same address. If you can, allow the admin pages (`/`, `/api/`, `/settings/`) only from your own network in the reverse proxy, and keep `/upload/`, `/base64/` and `/files/` open for your apps and visitors. ## Back up Copy the data folder on a schedule. See [Back up your data](../backups/). --- title: REST API overview project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/rest-api/ updated: 2026-11-19T07:45:44.888Z --- # REST API overview > The endpoints your apps call, how to send the token and what comes back. Your apps talk to OpenFiles over HTTP. The address of every endpoint starts with your OpenFiles address, for example `https://files.example.com`. ## Endpoints | Method and path | What it does | |---|---| | `POST /upload/{db}/` | [Upload files](../upload/) as `multipart/form-data`. | | `POST /files/{db}/` | The same as `/upload/{db}/`. | | `POST /base64/{db}/` | [Upload one file as Base64](../upload-base64/) in JSON. | | `GET /files/{db}/{id}-{checksum}.{ext}` | [Open or download a file](../file-links/). Public, no token. | `{db}` is the storage name, for example `photos`. The storage must exist; create it in [Storages](../../guides/storages/). ## Send the token Every upload needs an [API token](../../guides/api-tokens/). Send it in one of two ways: - as the `token` query argument: ```bash curl -F file=@sunset.png "https://files.example.com/upload/photos/?token=YOUR_TOKEN" ``` - or in the `x-token` header: ```bash curl -H "x-token: YOUR_TOKEN" -F file=@sunset.png "https://files.example.com/upload/photos/" ``` The header keeps the token out of server logs and browser history, so prefer it when your app can set headers. ## What comes back A successful upload answers `200` with JSON that describes the file: ```json {"id":"JapO3b1e961f","name":"sunset.png","size":2795,"type":"image/png","width":640,"height":480,"ext":"png","url":"/files/photos/JapO3b1e961f-pn.png"} ``` | Field | Meaning | |---|---| | `id` | The file ID in the storage. | | `name` | The file name. | | `size` | Size in bytes. | | `type` | The content type. | | `width`, `height` | Image size in pixels; `0` for other files. | | `ext` | The file extension. | | `url` | The [link](../file-links/) to the file. Relative, unless you add `hostname=1`. | Save `id` and `url` in your app. Errors come back as a JSON array with an `error` text. See [Errors and limits](../errors/). ## Cross-origin requests The upload endpoints allow cross-origin requests, so a web page on another domain can upload directly. See [Upload from a web page](../../recipes/upload-from-browser/). --- title: Upload files project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/upload/ updated: 2026-11-19T07:45:44.888Z --- # Upload files > POST /upload/{db}/: upload one or more files as multipart/form-data. ```text POST /upload/{db}/ POST /files/{db}/ ``` Both paths do the same. Send the files as `multipart/form-data`, with the [token](../rest-api/) in the `token` query argument or the `x-token` header. The token needs **Upload files** and the storage `{db}`. A request can be up to 100 MB. ## Query arguments | Argument | Meaning | |---|---| | `token` | The API token, if you do not use the `x-token` header. | | `hostname=1` | Return an absolute `url` with the OpenFiles address. | | `id` | Your own ID for the uploaded file. Use letters and digits only. | ## One file ```bash curl -H "x-token: YOUR_TOKEN" -F file=@sunset.png "https://files.example.com/upload/photos/" ``` The answer is one object: ```json {"id":"JapO3b1e961f","name":"sunset.png","size":2795,"type":"image/png","width":640,"height":480,"ext":"png","url":"/files/photos/JapO3b1e961f-pn.png"} ``` ## Several files Send several file fields in one request: ```bash curl -H "x-token: YOUR_TOKEN" -F file1=@sea.png -F file2=@forest.png "https://files.example.com/upload/photos/" ``` The answer is an array, one object per file: ```json [{"id":"JapO3b1f960f","name":"sea.png","size":3577,"type":"image/png","width":800,"height":600,"ext":"png","url":"/files/photos/JapO3b1f960f-pn.png"},{"id":"JapO3b1g961f","name":"forest.png","size":1591,"type":"image/png","width":400,"height":300,"ext":"png","url":"/files/photos/JapO3b1g961f-pp.png"}] ``` ## Absolute link and your own ID ```bash curl -H "x-token: YOUR_TOKEN" -F file=@sea.png "https://files.example.com/upload/photos/?id=homepagebanner&hostname=1" ``` ```json {"id":"homepagebanner","name":"sea.png","size":3577,"type":"image/png","width":800,"height":600,"ext":"png","url":"https://files.example.com/files/photos/homepagebanner-14s.png"} ``` You can also set the ID per file with a form field named after the file field plus `_id`. Here the file field is `file`, so the ID field is `file_id`: ```bash curl -H "x-token: YOUR_TOKEN" -F file=@forest.png -F file_id=forestthumb "https://files.example.com/upload/photos/" ``` ```json {"id":"forestthumb","name":"forest.png","size":1591,"type":"image/png","width":400,"height":300,"ext":"png","url":"/files/photos/forestthumb-xf.png"} ``` When you upload again with an ID that exists, the link serves the new file. See [Replace a file at the same link](../../recipes/replace-file/). ## Any kind of file Any file type is accepted. For files that are not images, `width` and `height` are `0`: ```json {"id":"JapO3b1h960f","name":"price-list.txt","size":38,"type":"text/plain","width":0,"height":0,"ext":"txt","url":"/files/photos/JapO3b1h960f-pp.txt"} ``` See [Errors and limits](../errors/) for the failures. --- title: Upload Base64 project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/upload-base64/ updated: 2026-11-19T07:45:44.888Z --- # Upload Base64 > POST /base64/{db}/: upload one file sent as a Base64 data URI in JSON. ```text POST /base64/{db}/ ``` Use this endpoint when your app has the file as a data URI, for example from a canvas or a clipboard paste. Send JSON with the [token](../rest-api/) in the `token` query argument or the `x-token` header. The token needs **Upload files** and the storage `{db}`. A request can be up to 10 MB. ## Body | Field | Meaning | |---|---| | `name` or `filename` | The file name, with extension. Required. | | `file` or `data` | The file as a data URI: `data:;base64,`. Required. | | `id` | Your own ID for the file (optional). Letters and digits only. | The query arguments `hostname=1` and `id` work as in [Upload files](../upload/). ## Example ```bash curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \ -d '{"name":"forest.png","file":"data:image/png;base64,iVBORw0KGgo..."}' \ "https://files.example.com/base64/photos/" ``` ```json {"id":"JapO3c1i961f","name":"forest.png","size":1591,"type":"image/png","ext":"png","width":400,"height":300,"url":"/files/photos/JapO3c1i961f-ps.png"} ``` ## Errors | Answer | Cause | |---|---| | `[{"error":"Invalid file name"}]` | No `name` or `filename`. | | `[{"error":"Invalid file type"}]` | `file` is not a data URI with a content type. | Both come with status `400`. See [Errors and limits](../errors/). --- title: File links project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/file-links/ updated: 2026-11-19T07:45:44.888Z --- # File links > The public link of a stored file, how to force a download and what the answer contains. Every file has a public link in this form: ```text /files/{db}/{id}-{checksum}.{ext} ``` For example `/files/photos/JapO3b1e961f-pn.png`. You get it in the `url` field of every upload answer. Use it as it is; do not build it yourself, because the checksum part is calculated by OpenFiles. ## Open a file The link needs no token and no sign-in. Anyone who has it can open the file, so put it in an `` tag, a page or an email: ```html Sunset ``` The answer has the file's content type. For images it also has the size in headers: ```text HTTP/1.1 200 OK x-width: 640 x-height: 480 x-size: 2795 content-type: image/png ``` ## Force a download Add `?download=1` to make the browser save the file under its name instead of showing it: ```text /files/photos/JapMXB1db60f-qt.png?download=1 ``` The answer then has: ```text content-disposition: attachment; filename*=utf-8''sunset.png ``` The name is the current file name, so a file you [renamed](../../guides/rename-remove-files/) downloads with its new name. ## When a link answers 404 - The file was removed, or its storage was dropped. - The checksum part is wrong, for example because the link was typed by hand. - The file was uploaded with an ID that contains a hyphen. Use IDs with letters and digits only. --- title: Errors and limits project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/errors/ updated: 2026-11-19T07:45:44.888Z --- # Errors and limits > The status codes and error texts of the upload API and its size limits. Errors come back as a JSON array with one object per error: ```json [{"error":"Not allowed"}] ``` ## Status codes | Status | Answer | Cause | |---|---|---| | `401` | `[{"error":"401: Unauthorized"}]` | No token, or the token is wrong. | | `400` | `[{"error":"Not allowed"}]` | The token lacks **Upload files** or the storage, or the storage does not exist. | | `400` | `[{"error":"Invalid file name"}]` | Base64 upload without `name`. | | `400` | `[{"error":"Invalid file type"}]` | Base64 upload whose `file` is not a data URI. | | `431` | (no JSON) | The request is larger than the limit. | | `404` | | A [file link](../file-links/) that does not point to a file. | See [Token permissions](../../guides/token-permissions/) to fix `Not allowed`. ## Size limits | Endpoint | Largest request | |---|---| | `POST /upload/{db}/`, `POST /files/{db}/` | 100 MB | | `POST /base64/{db}/` | 10 MB (the Base64 text, which is about a third larger than the file) | The limit is per request. To upload more data, send the files in several requests. --- title: The config file project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/config/ updated: 2026-11-19T07:45:44.888Z --- # The config file > The settings in the config file that you may change. The file `config` in the OpenFiles folder holds the start settings, one per line, as `key : value`. Lines that start with `//` are comments. Restart OpenFiles after you change it. The file as it comes: ```text name : OpenFiles app : openfiles icon : ti ti-copy cdn : https://cdn.componentator.com $api : /api/ $insecure : true // database : postgres://user:password@localhost/database ``` ## Settings you may change | Key | Meaning | |---|---| | `name` | The app name in the header and browser tab. A name saved in [Settings](../../guides/settings/) replaces it. | | `database` | A PostgreSQL connection that indexes the uploaded files. See [Index files in PostgreSQL](../../guides/postgresql/). | Leave the other keys as they are: the admin interface depends on them. The port is not in this file. Pass it on the command line, for example `node index.js 8080`. See [Install from source](../../guides/install-source/). --- title: The data folder project: OpenFiles version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/reference/data-folder/ updated: 2026-11-19T07:45:44.888Z --- # The data folder > What OpenFiles keeps in the databases folder. OpenFiles keeps all its data in the `databases` folder inside the OpenFiles folder. In the Docker image it is `/www/.src/databases`. | Item | What it holds | |---|---| | `fs-{storage}/` | One folder per [storage](../../guides/storages/), for example `fs-photos/`, with the files and their names and sizes. | | `memorize_account.json` | The admin account: name, login and the password hash. | | `memorize_data.json` | The [API tokens](../../guides/api-tokens/) and the [Settings](../../guides/settings/). | Changes to tokens and settings are written to `memorize_data.json` a few seconds after you save them. Do not edit the files by hand while OpenFiles runs. To keep your data safe, copy the whole folder. See [Back up your data](../../guides/backups/). --- title: Upload from Node.js project: OpenFiles version: 1.0 section: recipes language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/recipes/upload-from-nodejs/ updated: 2026-11-19T07:45:44.888Z --- # Upload from Node.js > Send a file from a Node.js app to OpenFiles and keep its link. Node.js has `fetch`, `FormData` and `Blob` built in, so you need no extra package. You need a storage (here `photos`) and a token with **Upload files** and **photos**. See [API tokens](../../guides/api-tokens/). **1.** Save this as `upload.js` and replace the address and the token: ```js const Fs = require('fs'); const OPENFILES = 'https://files.example.com'; const TOKEN = 'YOUR_TOKEN'; async function upload(path, name, type) { const form = new FormData(); form.append('file', new Blob([Fs.readFileSync(path)], { type }), name); const res = await fetch(OPENFILES + '/upload/photos/?hostname=1', { method: 'POST', headers: { 'x-token': TOKEN }, body: form }); if (!res.ok) throw new Error('Upload failed: ' + res.status + ' ' + await res.text()); return res.json(); } upload('sunset.png', 'sunset.png', 'image/png').then(console.log); ``` **2.** Run it: ```bash node upload.js ``` The answer describes the file: ```js { id: 'JapO8K1j960f', name: 'sunset.png', size: 2795, type: 'image/png', width: 640, height: 480, ext: 'png', url: 'https://files.example.com/files/photos/JapO8K1j960f-p9.png' } ``` **3.** Save `id` and `url` with your own record, for example the product the photo belongs to, and use `url` wherever you show the file. See [Upload files](../../reference/upload/) for all options. --- title: Upload from a web page project: OpenFiles version: 1.0 section: recipes language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/recipes/upload-from-browser/ updated: 2026-11-19T07:45:44.888Z --- # Upload from a web page > Let a web page on another domain upload a file directly to OpenFiles. The upload endpoints allow cross-origin requests, so a page on your website can send a file straight to OpenFiles. The token is visible to every visitor of the page. Create a separate token for the page with **Upload files** and one storage only, for example `uploads`. See [Token permissions](../../guides/token-permissions/). **1.** Add a file field and a script to your page: ```html

``` **2.** Open the page, choose a file, and the page shows its link. The answer is the same as in [Upload files](../../reference/upload/), for example: ```json {"id":"JapOAg1di60f","name":"forest.png","size":1591,"type":"image/png","width":400,"height":300,"ext":"png","url":"/files/photos/JapOAg1di60f-rg.png"} ``` When your server can do the upload instead, prefer that and keep the token on the server: see [Upload from Node.js](../upload-from-nodejs/). --- title: Replace a file at the same link project: OpenFiles version: 1.0 section: recipes language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/recipes/replace-file/ updated: 2026-11-19T07:45:44.888Z --- # Replace a file at the same link > Upload with your own ID so a new version of a file keeps the same link. When you upload with your own ID, the link depends only on the storage and that ID. Upload again with the same ID and the same link serves the new file, so pages that show it need no change. **1.** Upload the first version with an ID made of letters and digits: ```bash curl -H "x-token: YOUR_TOKEN" -F file=@sea.png "https://files.example.com/upload/photos/?id=homepagebanner" ``` ```json {"id":"homepagebanner","name":"sea.png","size":3577,"type":"image/png","width":800,"height":600,"ext":"png","url":"/files/photos/homepagebanner-14s.png"} ``` **2.** Later, upload the new version with the same ID: ```bash curl -H "x-token: YOUR_TOKEN" -F file=@sunset.png "https://files.example.com/upload/photos/?id=homepagebanner" ``` ```json {"id":"homepagebanner","name":"sunset.png","size":2795,"type":"image/png","width":640,"height":480,"ext":"png","url":"/files/photos/homepagebanner-14s.png"} ``` The `url` is the same, and it now serves `sunset.png`. Browsers may keep the old version in their cache for a while. If visitors must see the change at once, add a version to the link in your page, for example `homepagebanner-14s.png?v=2`. --- title: Sign-in project: OpenFiles version: 1.0 section: faq language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/faq/sign-in/ updated: 2026-11-19T07:45:36.793Z --- # Sign-in > Questions about the admin account and signing in. ## Where do I find the first password? On the sign-in page, in the **Default account** box, until the first successful sign-in. See [First sign-in](../../guides/first-sign-in/). ## I forgot my password. How do I get in? **1.** Stop OpenFiles. **2.** Move the account file out of the data folder: ```bash mv databases/memorize_account.json memorize_account.old.json ``` **3.** Start OpenFiles. It creates a new first-start account, and the sign-in page shows it in the **Default account** box. **4.** Sign in and set your own credentials. See [Your account](../../guides/account/). Your storages, files and API tokens stay as they are. ## Can several people have their own accounts? No. OpenFiles has one admin account. Share it only with people you trust, and give apps their own [API tokens](../../guides/api-tokens/) instead. ## Why was I signed out? A session lasts one month. A change of the **Login** in another browser also closes your session. --- title: Files and links project: OpenFiles version: 1.0 section: faq language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/faq/files/ updated: 2026-11-19T07:45:36.793Z --- # Files and links > Questions about uploading files and sharing their links. ## Are file links public? Yes. Anyone who has a link can open the file, without a token. Links are hard to guess, but do not store files in OpenFiles that only some people may see. ## How large can a file be? Up to 100 MB per request with `multipart/form-data`, and 10 MB per request with Base64. See [Errors and limits](../../reference/errors/). ## Which file types can I upload? Any type. For images OpenFiles also stores the width and height. ## How do I upload files? Through the REST API, from your app or with `curl`. See [Upload files](../../reference/upload/). ## A link answers 404. Why? The file or its storage was removed, the link was changed by hand, or the file ID contains a hyphen. See [File links](../../reference/file-links/). ## Can I keep the same link for a new version of a file? Yes, upload it with your own ID. See [Replace a file at the same link](../../recipes/replace-file/). --- title: API tokens project: OpenFiles version: 1.0 section: faq language: en license: MIT url: https://totaljs.es/docs/openfiles/1-0/faq/tokens/ updated: 2026-11-19T07:45:36.793Z --- # API tokens > Questions about API tokens and permissions. ## My upload answers "Not allowed". What is missing? The token needs both **Upload files** and the name of the storage you upload to, and the storage must exist. See [Token permissions](../../guides/token-permissions/). ## My upload answers 401. Why? The token is missing, mistyped, or it was removed. Copy it again from **API Tokens**. See [API tokens](../../guides/api-tokens/). ## Do tokens expire? No. A token works until you remove it. ## Can I see which app uploaded a file? Yes, if you [index files in PostgreSQL](../../guides/postgresql/): the `createdby` column holds the **App name** of the token. The token card in **API Tokens** also shows when the token was last used. ## Should I put a token in a web page? Only a token made for that page, with **Upload files** and one storage. See [Upload from a web page](../../recipes/upload-from-browser/).