For the complete documentation index, see llms.txt. This page is also available as Markdown.

Local Link Transform Scripts

Convert, split or rename files in VARIO Local Link before a watch folder uploads them to the DMS.

A transform script is a Node.js module that VARIO Local Link runs on every file a watch folder picks up, before the file is uploaded to the DMS. Use it to fix an encoding, split one file into several, rename a file or convert a format the import cannot read.

Transform scripts are not VARIO Cloud scripts. They do not run on the server, have no ctx and no access to the VARIO Cloud services. For server-side processing after the upload, link the DMS document type to an automated import or script processing (see Batch Processing).


Runtime

Aspect
Behaviour

Engine

The Node.js process of VARIO Local Link (Node 24), not the GraalJS engine of VARIO Cloud scripts

Module format

CommonJS. module.exports must be a function.

Rights

Those of the account the Local Link service runs under. The script can read and write files, start processes and open network connections.

Modules

Node built-ins (fs, path, zlib, …) and any package installed next to the script with npm install

Reloading

The script file is reloaded when its modification time changes. Helper modules loaded with require() stay cached until Local Link restarts.


Setup

  1. Save the script as a .js file on the machine running Local Link, e.g. C:\VARIO\transform\csv-to-utf8.js.

  2. In Local Link, open Datentransfer → Datenimporte → Ordner überwachen and edit the watch folder.

  3. Enter the absolute path of the file in Transform-Skript (optional) and save.

From now on, every file the watch folder picks up passes through the script. Watch folders without a script upload the file unchanged.


Input

The function receives one object:

Property
Type
Description

buffer

Buffer

Content of the source file

path

string

Path of the copy in the Local Link queue, not the path in the watched folder

filename

string

Original file name, e.g. orders_2026-10-06.csv

signal

AbortSignal

Aborted when the upload is cancelled or Local Link shuts down

Use path to stream large files instead of working on buffer.


Return Values

A script can return a single file, a list of files or stream files one by one.

Form
Return value
Use for

Single file

{ buffer, filename, mimeType? }

Converting or renaming one file

Several files

{ files: [{ buffer, filename, mimeType? }, …] }

Splitting a file into a few parts

Streaming

async function* that yields { buffer, filename, mimeType? }

Splitting very large files; only one part is held in memory at a time

Field
Rule

buffer

Must be a Node Buffer. Convert a Uint8Array with Buffer.from(...).

filename

Non-empty string. Becomes the file name and the description of the DMS document.

mimeType

Optional. Sent as the content type of the upload.

At least one file must be returned.


What Happens With the Result

  • Each returned file becomes its own DMS document. DMS document type, tags and the link to an automated import are taken from the watch folder, so every part is processed like a file that was dropped into the folder on its own.

  • Fixed document (Fortlaufende Revision): If the watch folder adds new revisions to one fixed DMS document, the script may return exactly one file. A second file fails with transform_multi_output_not_compatible_with_fixed_dmsResource.

  • Crash safety: The parts are written to <import directory>/sub-queue/<key>/ together with a manifest.json before the upload starts. If Local Link stops after the script has finished, the upload resumes with the stored parts and the script does not run again. If it stops while the script is still running, the parts are discarded and the script runs again.

  • Partial failure: If some parts fail to upload, the source file is moved to Fehlgeschlagen with the error partial_upload_failed: 2/5 files failed. Fehlgeschlagene Sub-Files wiederholen uploads only the failed parts again, without running the script a second time.


Errors

Error
Cause

transform_script_not_found: <path>

No file at the configured path

transform_script_must_export_function

module.exports is not a function

transform_script_invalid_result

The script returned nothing, or a single file without a Buffer or file name

transform_script_empty_files

files is empty or the generator yielded nothing

transform_script_invalid_file_buffer_at_<i>

Part number <i> (0-based) has no Buffer

transform_script_invalid_file_filename_at_<i>

Part number <i> has no file name

transform_multi_output_not_compatible_with_fixed_dmsResource

More than one part for a watch folder with a fixed DMS document

Errors thrown by the script and the errors above are reported as transform_script_failed: <message>. The source file then appears under Fehlgeschlagen and can be retried there.


Examples

Convert a Latin-1 CSV to UTF-8

Split a CSV into one file per order number

Stream a large file in chunks

Split a PDF into single pages

Run npm install pdf-lib in the folder of the script first.

Was this helpful?