Local File Sink¶
Class: LocalFileSinkBlockV1
Source: inference.core.workflows.core_steps.sinks.local_file.v1.LocalFileSinkBlockV1
Save workflow data as files on the local filesystem, supporting CSV, JSON, and text file formats with configurable output modes for aggregating multiple entries into single files or saving each entry separately, enabling persistent data storage, logging, and file-based data export.
How This Block Works¶
This block writes string content from workflow steps to files on the local filesystem. The block:
- Takes string content (from formatters, predictions, or other string-producing blocks) and file configuration as input
- Validates filesystem access permissions (checks if local storage access is allowed based on environment configuration)
- Verifies write permissions for the target directory (checks against allowed write directory restrictions if configured)
- Selects the appropriate file saving strategy based on
output_mode: - Separate Files Mode: Creates a new file for each input, generating unique filenames with timestamps
- Append Log Mode: Appends content to an existing file (or creates a new one if needed), aggregating multiple entries
- For separate files mode: Generates a unique file path using the target directory, file name prefix, file type, and a timestamp, then writes the content to the new file
- For append log mode:
- Opens or creates a file based on the file name prefix and type
- Applies format-specific handling for appending:
- CSV: Removes the header row from subsequent appends (CSV content must include headers on first write)
- JSON: Converts to JSONL (JSON Lines) format, parsing and re-serializing each JSON document to fit on a single line
- TXT: Appends content directly with newlines
- Tracks entry count and creates a new file when
max_entries_per_filelimit is reached - Creates parent directories if they don't exist
- Writes content to the file (ensuring newline termination)
- Returns error status and messages indicating save success or failure
The block supports two distinct storage strategies: separate files mode creates individual timestamped files for each input (useful for organizing outputs by execution), while append log mode aggregates multiple entries into continuous log files (useful for time-series data logging). The file path generation includes timestamps (format: YYYY_MM_DD_HH_MM_SS_microseconds) to ensure unique filenames and chronological organization. In append log mode, the block maintains file handles across executions and automatically handles file rotation when entry limits are reached.
Requirements¶
Local Filesystem Access: This block requires write access to the local filesystem. Filesystem access can be controlled via environment variables:
- Set ALLOW_WORKFLOW_BLOCKS_ACCESSING_LOCAL_STORAGE=False to disable local file sink functionality (block will raise an error)
- Set WORKFLOW_BLOCKS_WRITE_DIRECTORY to an absolute path to restrict writes to a specific directory and its subdirectories only
Note on Append Log Mode Format Handling:
- For CSV files in append mode, the content must include header rows on the first write; headers are automatically removed from subsequent appends
- For JSON files in append mode, files are saved with .jsonl extension in JSON Lines format (one JSON object per line)
Common Use Cases¶
- Data Logging and Audit Trails: Save workflow execution data, detection results, or metrics to local log files (e.g., append CSV logs of detections, JSON logs of workflow outputs), enabling persistent logging and audit trails for production workflows
- File-Based Data Export: Export formatted workflow data to files for external processing (e.g., save CSV exports from CSV Formatter, JSON exports for downstream tools), enabling integration with file-based data processing pipelines
- Time-Series Data Collection: Aggregate workflow metrics over time into continuous log files (e.g., append CSV rows with timestamps, log detection counts per frame), creating persistent time-series datasets for analysis and reporting
- Batch Result Storage: Save individual results from batch processing workflows to separate files (e.g., save each image's detection results to separate JSON files), enabling organized storage of batch processing outputs with unique filenames
- Data Archival: Archive workflow outputs and results to local storage (e.g., save formatted reports, export analysis results), enabling long-term data retention and backup workflows
- Integration with File-Based Systems: Store workflow data in file formats compatible with external tools (e.g., save CSV for spreadsheet analysis, JSONL for data processing pipelines), enabling seamless data exchange with file-based systems
Connecting to Other Blocks¶
This block receives string content from workflow steps and saves it to files:
- After formatter blocks (e.g., CSV Formatter) to save formatted data (CSV, JSON, or text) to files, enabling persistent storage of structured workflow outputs
- After detection or analysis blocks that output string-format data to save inference results, metrics, or analysis outputs to files for logging or archival
- After data processing blocks (e.g., Expression, Property Definition) that produce string outputs to save computed or transformed data to files
- In logging workflows to create persistent audit trails and logs of workflow executions, enabling record-keeping and debugging for production deployments
- In batch processing workflows where multiple data points need to be saved (either aggregated into log files or stored as separate files), enabling organized data collection and storage
- Before external processing where workflow data needs to be saved to files for consumption by external tools, scripts, or systems that read from filesystem storage
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/local_file_sink@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
file_type |
str |
Type of file to create: 'csv' (CSV format), 'json' (JSON format, or JSONL in append_log mode), or 'txt' (plain text). The content format should match this file type. In append_log mode, JSON files are saved as .jsonl (JSON Lines) format with one JSON object per line.. | ❌ |
output_mode |
str |
File organization strategy: 'append_log' aggregates multiple content entries into a single file (useful for time-series logging, creates files that grow over time), or 'separate_files' creates a new file for each input (useful for organizing individual outputs, each file gets a unique timestamp-based filename). In append_log mode, the block handles format-specific appending (removes CSV headers, converts JSON to JSONL).. | ❌ |
target_directory |
str |
Directory path where files will be saved. Can be a relative or absolute path. Parent directories are created automatically if they don't exist. If WORKFLOW_BLOCKS_WRITE_DIRECTORY is set, this path must be a subdirectory of the allowed directory. Files are saved with filenames generated from file_name_prefix and timestamps.. | ✅ |
file_name_prefix |
str |
Prefix used to generate filenames. Combined with a timestamp (format: YYYY_MM_DD_HH_MM_SS_microseconds) and file extension to create unique filenames like 'workflow_output_2024_10_18_14_09_57_622297.csv'. For append_log mode, new files are created when max_entries_per_file is reached, using this prefix with new timestamps.. | ✅ |
max_entries_per_file |
int |
Maximum number of entries (content appends) allowed per file in append_log mode. When this limit is reached, a new file is created with the same file_name_prefix and a new timestamp. Only applies when output_mode is 'append_log'. Must be at least 1. Use this to control file sizes and enable file rotation for long-running workflows.. | ✅ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Runtime compatibility¶
-
soft— runtimededicated_deployment - Files are persisted on the deployment's volume but are not retrievable through the Roboflow API; treat as internal-only logs.
-
soft— runtimehosted_serverless - Container disk is ephemeral, so files are lost when the worker scales down; if there's more than one replica consuming workflow requests the result will be non deterministic..
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Local File Sink in version v1.
- inputs:
VLM As Classifier,Google Gemma API,MoonshotAI Kimi,Stitch OCR Detections,Anthropic Claude,S3 Sink,LMM For Classification,Microsoft SQL Server Sink,Roboflow Custom Metadata,Google Vision OCR,Twilio SMS Notification,Qwen-VL,Email Notification,Roboflow Vision Events,Stitch OCR Detections,Google Gemma,Event Writer,Qwen3.5-VL,Llama 3.2 Vision,Email Notification,Twilio SMS/MMS Notification,OPC UA Writer Sink,Llama 3.2 Vision,Model Monitoring Inference Aggregator,OpenRouter,OpenAI,Florence-2 Model,OpenAI-Compatible LLM,MoonshotAI Kimi,OpenAI,Single-Label Classification Model,OCR Model,CogVLM,Instance Segmentation Model,Anthropic Claude,Google Gemini,Qwen 3.6 API,Clip Comparison,Google Gemini,CSV Formatter,Webhook Sink,Multi-Label Classification Model,LMM,OpenAI,Florence-2 Model,Current Time,OpenAI,VLM As Detector,Google Gemini,Roboflow Visual Search,Slack Notification,EasyOCR,Roboflow Dataset Upload,Roboflow Dataset Upload,PLC Writer,Qwen 3.5 API,Anthropic Claude,Object Detection Model,Local File Sink,MQTT Writer,Keypoint Detection Model,GLM-OCR,Roboflow Asset Library Attributes - outputs:
Line Counter,MoonshotAI Kimi,Stability AI Image Generation,Trace Visualization,Path Deviation,Image Stack,Anthropic Claude,Icon Visualization,SIFT Comparison,Morphological Transformation,Color Visualization,LMM For Classification,Single-Label Classification Model,Perspective Correction,Corner Visualization,Roboflow Custom Metadata,Halo Visualization,Dynamic Zone,Keypoint Detection Model,Qwen-VL,Email Notification,Halo Visualization,Object Detection Model,Google Gemma,Background Color Visualization,Ellipse Visualization,Email Notification,Twilio SMS/MMS Notification,Text Display,Polygon Visualization,Crop Visualization,Image Preprocessing,Template Matching,Model Monitoring Inference Aggregator,OpenRouter,OpenAI,Florence-2 Model,Motion Detection,Heatmap Visualization,OpenAI,Perception Encoder Embedding Model,Blur Visualization,Depth Estimation,Instance Segmentation Model,Stability AI Outpainting,Anthropic Claude,YOLO-World Model,Google Gemini,Clip Comparison,Google Gemini,Keypoint Visualization,Webhook Sink,Florence-2 Model,Current Time,Contrast Equalization,OpenAI,Moondream2,Line Counter,Google Gemini,Slack Notification,Triangle Visualization,Time in Zone,CLIP Embedding Model,Multi-Label Classification Model,Local File Sink,Keypoint Detection Model,Pixel Color Count,GLM-OCR,Roboflow Asset Library Attributes,Polygon Zone Visualization,Time in Zone,Google Gemma API,Stitch OCR Detections,Line Counter Visualization,Semantic Segmentation Model,Distance Measurement,Image Threshold,Multi-Label Classification Model,Camera Calibration,QR Code Generator,S3 Sink,Microsoft SQL Server Sink,Twilio SMS Notification,Google Vision OCR,Image Blur,Morphological Transformation,Roboflow Vision Events,Size Measurement,PTZ Tracking (ONVIF),Stability AI Inpainting,Classification Label Visualization,Stitch OCR Detections,Event Writer,Qwen3.5-VL,Mask Visualization,Llama 3.2 Vision,Reference Path Visualization,Label Visualization,OPC UA Writer Sink,Dot Visualization,Cache Set,Dynamic Crop,Detections Stitch,Circle Visualization,Llama 3.2 Vision,BoT-SORT Tracker,Path Deviation,SAM3 Video Tracker,Gaze Detection,Segment Anything 2 Model,OpenAI-Compatible LLM,MoonshotAI Kimi,Single-Label Classification Model,CogVLM,Object Detection Model,SAM 3 Interactive,Qwen 3.6 API,Detections Consensus,Bounding Box Visualization,Multi-Label Classification Model,LMM,OpenAI,SAM 3,Instance Segmentation Model,Roboflow Visual Search,Roboflow Dataset Upload,SAM 3,Cache Get,Instance Segmentation Model,Detections Classes Replacement,Pixelate Visualization,Keypoint Detection Model,Instance Segmentation Model,Roboflow Dataset Upload,PLC Writer,Qwen 3.5 API,Object Detection Model,Anthropic Claude,Time in Zone,MQTT Writer,Polygon Visualization,SAM 3,Model Comparison Visualization,Single-Label Classification Model,Seg Preview
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Local File Sink in version v1 has.
Bindings
-
input
content(string): String content to save as a file. This should be formatted data from other workflow blocks (e.g., CSV content from CSV Formatter, JSON strings, or plain text). The content format should match the specified file_type. For CSV files in append_log mode, content must include header rows on the first write..target_directory(string): Directory path where files will be saved. Can be a relative or absolute path. Parent directories are created automatically if they don't exist. If WORKFLOW_BLOCKS_WRITE_DIRECTORY is set, this path must be a subdirectory of the allowed directory. Files are saved with filenames generated from file_name_prefix and timestamps..file_name_prefix(string): Prefix used to generate filenames. Combined with a timestamp (format: YYYY_MM_DD_HH_MM_SS_microseconds) and file extension to create unique filenames like 'workflow_output_2024_10_18_14_09_57_622297.csv'. For append_log mode, new files are created when max_entries_per_file is reached, using this prefix with new timestamps..max_entries_per_file(string): Maximum number of entries (content appends) allowed per file in append_log mode. When this limit is reached, a new file is created with the same file_name_prefix and a new timestamp. Only applies when output_mode is 'append_log'. Must be at least 1. Use this to control file sizes and enable file rotation for long-running workflows..
-
output
Example JSON definition of step Local File Sink in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/local_file_sink@v1",
"content": "$steps.csv_formatter.csv_content",
"file_type": "csv",
"output_mode": "append_log",
"target_directory": "some/location",
"file_name_prefix": "my_file",
"max_entries_per_file": 1024
}