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