Local Storage

Read and write files on the server's local file system from your Spala flows.

Local Storage

The Local Storage addon provides managed file operations for reading, writing, and organizing project files. Use it for uploads, temporary file processing, export generation, and workflows that need file storage.

Installation

1. Enable the Local Storage addon from the Addons panel
2. Optionally configure the base storage directory

Configuration

Available Steps

Save File

Writes content to a file on the local file system.

Read File

Reads the contents of a file.

Delete File

Deletes a file from the file system.

List Files

Lists files in a directory.

File Exists

Checks whether a file exists at the given path.

Example: File Upload Endpoint

// POST /api/files/upload

// Step 1: Set Variable - Generate unique filename
// vars.filename = Date.now() + '-' + input.originalName
// Step 2: Save File (Local Storage addon)
// path: 'uploads/' + vars.auth.userId + '/' + vars.filename
// content: input.fileData
// encoding: 'base64'
// Step 3: Database Query - Save file record
// INSERT INTO files (user_id, filename, path, size, mime_type)
// VALUES (vars.auth.userId, input.originalName, 'uploads/' + vars.auth.userId + '/' + vars.filename, input.fileSize, input.mimeType)
// RETURNING *
// Step 4: Response
// { file: vars.fileRecord }

Example: Export to CSV

// GET /api/reports/export

// Step 1: Database Query - Get report data
// SELECT * FROM orders WHERE created_at >= input.startDate
// Step 2: Set Variable - Build CSV content
// vars.csv = 'id,customer,total,status,date\n' +
//   vars.orders.map(o => [o.id, o.customer_name, o.total, o.status, o.created_at].join(',')).join('\n')
// Step 3: Save File (Local Storage addon)
// path: 'exports/orders-' + Date.now() + '.csv'
// content: vars.csv
// encoding: 'utf8'
// Output → vars.filePath
// Step 4: Response
// { downloadPath: vars.filePath }

All file paths are sandboxed to the configured storage directory. Attempting to access files outside this directory (e.g., using "../" path traversal) will be blocked for security.

For production deployments with multiple server instances, consider using the AWS S3 addon instead of local storage. Local storage is tied to a single server and files will not be available across instances.

Base directory for file operations (default: './storage' relative to the project root). All file paths are resolved relative to this directory.
File path relative to the storage directory (e.g., 'uploads/report.pdf').
File content — a string, Buffer, or base64-encoded data.
'utf8' (default), 'base64', 'binary', or 'buffer'.
File path relative to the storage directory.
'utf8' (default), 'base64', 'binary', or 'buffer'.
File path relative to the storage directory.
Directory path relative to the storage directory (default: root '/').
Whether to list files in subdirectories (default: false).
File path to check.
Addons Overview
/addons
Browse available addons
Installing Addons
/addons/installing
Enable and configure addons in your project