Skip to content

bonsaedev/node-red-file-storage

Repository files navigation

@bonsae/node-red-file-storage

File storage nodes for Node-RED built with @bonsae/nrg. Read, write, and watch files across multiple storage backends with a unified API.

Supported Backends

Backend Adapter Use Case
Local File System @flystorage/local-fs Development, edge deployments
Amazon S3 @flystorage/aws-s3 Also works with R2, DigitalOcean Spaces, MinIO
Google Cloud Storage @flystorage/google-cloud-storage GCP workloads
Azure Blob Storage @flystorage/azure-storage-blob Azure workloads

Installation

npm install @bonsae/node-red-file-storage

Cloud SDKs are optional dependencies. They are only needed if you use the corresponding backend:

# For S3
npm install @aws-sdk/client-s3

# For Google Cloud Storage
npm install @google-cloud/storage

# For Azure Blob Storage
npm install @azure/storage-blob

Nodes

File Storage (Configuration)

Configures a storage backend shared by File Read, File Write, and File Watch nodes. Each backend has its own set of configuration fields:

  • Local: Root directory path
  • S3: Bucket, region, optional prefix. Credentials via Access Key ID / Secret Access Key
  • GCS: Bucket, project ID, optional prefix. Credentials via service account key file
  • Azure: Container, optional prefix. Credentials via connection string

File Read

Reads a file from the configured storage backend.

Config:

  • Storage - File Storage configuration node
  • File Path - Path relative to the storage root (supports str or msg types)
  • Output As - string, buffer, or stream
  • Encoding - Character encoding when output is string (UTF-8, ASCII, Latin-1, etc.)

Input: Any message triggers the read.

Output:

  • msg.payload - File content as string, Buffer, or Readable stream
  • msg.filename - Path of the file that was read

File Write

Writes, appends, or deletes a file in the configured storage backend.

Config:

  • Storage - File Storage configuration node
  • File Path - Path relative to the storage root (supports str or msg types)
  • Action - overwrite, append, or delete
  • Create Directory - Auto-create parent directories if they don't exist
  • Add Newline - Append a trailing newline after data (append mode only)
  • Encoding - Character encoding when writing string content

Input: msg.payload as string, Buffer, or Readable stream.

Output:

  • msg.filename - Path of the file that was written/deleted

File Watch

Watches a directory on the local file system for file changes. No input port -- emits events automatically when files are created, modified, or deleted.

Config:

  • Storage - File Storage configuration node (must be local file system)
  • Watch Path - Subdirectory to watch (empty = entire root)
  • Recursive - Watch subdirectories recursively

Output:

  • msg.payload - Relative path of the changed file
  • msg.event - created, modified, or deleted
  • msg.filename - Relative path of the changed file

File Watch only works with the Local File System backend. Selecting a non-local storage will show an error.

Development

# Install dependencies
pnpm install

# Start dev server (Node-RED with hot reload)
pnpm dev

# Build for production
pnpm build

# Run checks
pnpm tsc:client && pnpm tsc:server
pnpm lint
pnpm format:check
pnpm test

License

BUSL-1.1

About

File Storage nodes for Node-RED with streaming support

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors