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.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Local File Sink in version v1.
- inputs:
Roboflow Dataset Upload,Object Detection Model,Email Notification,Google Gemma API,OCR Model,Google Vision OCR,Google Gemini,Instance Segmentation Model,EasyOCR,OpenAI,Anthropic Claude,Webhook Sink,Stitch OCR Detections,Roboflow Custom Metadata,Qwen 3.5 API,OpenAI,Single-Label Classification Model,VLM As Classifier,Qwen 3.6 API,Florence-2 Model,CogVLM,Florence-2 Model,GLM-OCR,S3 Sink,Twilio SMS Notification,Model Monitoring Inference Aggregator,Local File Sink,Google Gemini,Roboflow Dataset Upload,Twilio SMS/MMS Notification,Anthropic Claude,Clip Comparison,CSV Formatter,VLM As Detector,LMM,Anthropic Claude,Multi-Label Classification Model,Roboflow Vision Events,OpenAI,Google Gemini,Qwen3.5-VL,LMM For Classification,OpenAI,Keypoint Detection Model,MoonshotAI Kimi,Llama 3.2 Vision,Email Notification,Slack Notification,Stitch OCR Detections - outputs:
Roboflow Dataset Upload,Line Counter Visualization,Gaze Detection,Instance Segmentation Model,Distance Measurement,Color Visualization,Multi-Label Classification Model,Ellipse Visualization,Polygon Visualization,Single-Label Classification Model,Detections Consensus,Detections Classes Replacement,Cache Set,Webhook Sink,Trace Visualization,Object Detection Model,Stitch OCR Detections,Qwen 3.5 API,OpenAI,SAM 3,Size Measurement,Image Threshold,Heatmap Visualization,Florence-2 Model,Halo Visualization,Path Deviation,GLM-OCR,Dot Visualization,S3 Sink,Path Deviation,Semantic Segmentation Model,Twilio SMS Notification,Seg Preview,Model Monitoring Inference Aggregator,Google Gemini,Roboflow Dataset Upload,Dynamic Zone,Pixelate Visualization,Line Counter,Twilio SMS/MMS Notification,Polygon Zone Visualization,Motion Detection,Blur Visualization,Text Display,Stability AI Image Generation,Perspective Correction,Anthropic Claude,Line Counter,Bounding Box Visualization,Depth Estimation,Stability AI Inpainting,Polygon Visualization,Roboflow Vision Events,Google Gemini,Label Visualization,Contrast Equalization,Triangle Visualization,Halo Visualization,Circle Visualization,Segment Anything 2 Model,Mask Visualization,OpenAI,MoonshotAI Kimi,Llama 3.2 Vision,Email Notification,Slack Notification,CLIP Embedding Model,Detections Stitch,Object Detection Model,Email Notification,Google Gemma API,Stability AI Outpainting,Google Vision OCR,Google Gemini,Image Preprocessing,Object Detection Model,OpenAI,Anthropic Claude,Time in Zone,Model Comparison Visualization,Roboflow Custom Metadata,YOLO-World Model,Instance Segmentation Model,Perception Encoder Embedding Model,Single-Label Classification Model,Template Matching,Qwen 3.6 API,SIFT Comparison,Morphological Transformation,Instance Segmentation Model,CogVLM,Crop Visualization,Camera Calibration,Florence-2 Model,Multi-Label Classification Model,Time in Zone,SAM 3,Icon Visualization,Local File Sink,Keypoint Detection Model,Time in Zone,Reference Path Visualization,Anthropic Claude,Clip Comparison,LMM,Pixel Color Count,Multi-Label Classification Model,Classification Label Visualization,Image Blur,SAM 3,Single-Label Classification Model,OpenAI,Corner Visualization,Keypoint Detection Model,Dynamic Crop,Keypoint Visualization,Moondream2,QR Code Generator,LMM For Classification,Morphological Transformation,Keypoint Detection Model,Background Color Visualization,PTZ Tracking (ONVIF),Stitch OCR Detections,Cache Get
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
}