Skip to main content

File Storage Overview

The FILE_STORAGE connector writes MQTT messages to local CSV or JSON files. It provides simple persistence for logging, backups, and data export without requiring a database server.
File storage is ideal for simple logging, local backups, and exporting data for offline analysis. Use it when you don’t need a full database but want persistent records.

Basic Syntax


Connection Configuration

FILE_STORAGE_CONFIG Parameters

string
required
Directory path for storing files.
string
File name pattern. {0} is replaced with the table name. Default: {0}.csv for CSV and {0}.json for JSON.{0} is the only placeholder. Others, such as {date}, are not supported: the connector fails when it writes. For daily files, publish to a table name that includes the date.
string
File format: CSV or JSON. Default: JSON.
string
CSV delimiter character. Default: comma (,).
boolean
Append to existing files. Default: true.
boolean
Auto-add timestamp field. Default: false.
integer
JSON only: the most records a file keeps. Older records are dropped once the file is full. Default: 10000. Files are not rotated.
string
Timestamp format string. Default: yyyy-MM-dd HH:mm:ss.
Use environment variables for paths in production. Keep deployment-specific values out of your connector definitions:
See Environment Variables & Secrets for setup and usage.

CLEAN Query Format

File storage connectors use the CLEAN format:
The table name is used in the file pattern with {0}.

Writing Data

Log sensor data to daily CSV files:
Creates files like: sensor_data_2025-01-15.csv
Alternative: STORE IN with Models — Instead of writing EVENT queries, you can bind a model directly to this connector. Every PUBLISH MODEL call automatically inserts a row — no query needed:
See Data Storage Overview for the full STORE IN workflow.

Reading Data

EVENTs also support read queries to retrieve data from stored files. Publish a message to the event’s SOURCE_TOPIC, and the query result is published to DESTINATION_TOPIC. File Storage read queries use the CLEAN format with filter, sort, and limit instead of SQL:
To trigger this query, publish the sensor ID to the source topic:
The matching record is published to file/result/latest, where your actions or external clients can consume it.

CLEAN Read Operators


File Pattern Placeholders

{0} is the only supported placeholder. A pattern with others, such as {date}, fails when the connector writes.

Output Examples

CSV Output

JSON Output (JSON Lines format)


Troubleshooting

  • Verify STORAGE_DIR exists
  • Check write permissions on directory
  • Ensure Coreflux process has access
  • Verify STORAGE_DIR path is correct
  • Check disk space is available
  • Ensure directory is writable
  • Verify SOURCE_TOPIC matches incoming messages
  • Check QUERY syntax is correct
  • Verify APPEND is set correctly
  • FILE_PATTERN accepts only {0} (the table name). Remove other placeholders such as {date}.
  • For JSON, MAX_RECORDS caps the file and drops the oldest records. Files are not rotated.

Next Steps

Data Storage Connectors Overview

Compare all storage options.

PostgreSQL Connector

Configure PostgreSQL database storage.
Last modified on October 22, 2026