This page covers Langflow's file management system, including storage backends (Local, S3, and Google Drive), the underlying service architecture, API endpoints, and specialized file components for reading and processing data.
Langflow's file management system provides centralized storage accessible to flows and components. The system uses a StorageService abstraction to handle file operations across different backends, ensuring consistency whether files are stored locally or in the cloud.
Key Characteristics:
flow_id src/backend/base/langflow/api/v1/files.py118-120 or user_id, ensuring that data is partitioned and secure._validated_path method in LocalStorageService centralizes checks for dangerous sequences like .., /, or \ src/backend/base/langflow/services/storage/local.py43-69get_flow dependency validates flow ownership before file access src/backend/base/langflow/api/v1/files.py70-80max_file_size_upload setting, typically defaulting to 10MB or 100MB depending on environment configuration src/backend/base/langflow/api/v1/files.py103-110The following diagram maps the relationship between the API layer, the Service layer, and the physical storage entities.
File Storage Entity Mapping
Sources: src/backend/base/langflow/api/v1/files.py26-29 src/backend/base/langflow/services/storage/local.py25-40 src/backend/base/langflow/api/v1/files.py70-80 src/lfx/src/lfx/components/files_and_knowledge/file.py105-115 src/lfx/src/lfx/components/files_and_knowledge/save_file.py68-78
The LocalStorageService handles files on the local disk. It resolves logical paths (formatted as flow_id/filename) into absolute filesystem paths using the configuration provided by SettingsService src/backend/base/langflow/services/storage/local.py103-118
aiofiles for asynchronous I/O operations src/backend/base/langflow/services/storage/local.py8flow_id and file_name to prevent traversal. It resolves the absolute path and ensures it remains within the data_dir boundary src/backend/base/langflow/services/storage/local.py71-86Langflow supports cloud providers for file persistence, primarily used by the FileComponent and SaveToFileComponent.
aiobotocore for operations. Requires aws_access_key_id, aws_secret_access_key, and bucket_name src/lfx/src/lfx/components/files_and_knowledge/save_file.py144-167 The S3StorageService validates identifiers to prevent path traversal and builds the full S3 key using a configurable prefix src/backend/base/langflow/services/storage/s3.py68-113Sources: src/backend/base/langflow/services/storage/local.py1-177 src/backend/base/langflow/services/storage/s3.py1-300 src/lfx/src/lfx/components/files_and_knowledge/file.py170-185 src/lfx/src/lfx/components/files_and_knowledge/save_file.py144-167
The FileComponent is the primary node for loading data into a flow. It supports standard text parsing and advanced document processing src/lfx/src/lfx/components/files_and_knowledge/file.py46-55
subprocess to prevent memory growth in the main application src/lfx/src/lfx/components/files_and_knowledge/file.py5-9_process_docling_in_subprocess method handles the communication with the parser and returns structured Data or Markdown src/lfx/src/lfx/components/files_and_knowledge/file.py188-197update_outputs method dynamically adjusts the component's outputs based on the file type and whether advanced mode is enabled. For example, a single CSV file will expose dataframe and message outputs, while a PDF in advanced mode will expose advanced_dataframe and advanced_markdown src/lfx/src/lfx/components/files_and_knowledge/file.py300-360The SaveToFileComponent allows flows to export data to various formats including CSV, JSON, Excel, and Markdown src/lfx/src/lfx/components/files_and_knowledge/save_file.py48-65
The BaseFileComponent provides the foundation for file-handling nodes, managing a per-instance _load_files_base_lock to prevent race conditions during concurrent file loads src/lfx/src/lfx/base/data/base_file.py123-131
Component File Processing Logic
Sources: src/lfx/src/lfx/base/data/base_file.py29-37 src/lfx/src/lfx/components/files_and_knowledge/file.py57-89 src/lfx/src/lfx/components/files_and_knowledge/save_file.py40-46 src/lfx/src/lfx/components/files_and_knowledge/file.py300-360
POST /files/upload/{flow_id} handles uploading files to a specific flow's storage src/backend/base/langflow/api/v1/files.py83-91 It enforces FlowAction.WRITE permissions src/backend/base/langflow/api/v1/files.py94-101 The UploadFileResponse schema is used for the response src/backend/base/langflow/api/v1/files.py91GET /files/download/{flow_id}/{file_name} serves files as a StreamingResponse with appropriate content types src/backend/base/langflow/api/v1/files.py125-154 The file_name is validated using ValidatedFileName to prevent path traversal src/backend/base/langflow/api/v1/files.py127GET /files/images/{flow_id}/{file_name} specifically handles image retrieval for browser rendering, also using ValidatedFileName src/backend/base/langflow/api/v1/files.py157-164GET /files/profile_pictures/{folder_name}/{file_name} allows retrieval of profile pictures from predefined folders, with folder_name and file_name validated src/backend/base/langflow/api/v1/files.py183-190The frontend interacts with these API endpoints for file management. For example, use-get-download-files.ts and use-get-download-flows.ts are hooks used for downloading files and flows respectively src/frontend/src/controllers/API/queries/file-management/use-get-download-files.ts src/frontend/src/controllers/API/queries/flows/use-get-download-flows.ts
Langflow starter projects often include file-related components. For example, the "Structured Data Analysis Agent" uses a FileDescriptionGeneratorComponent to ingest data into Chroma src/backend/base/langflow/initial_setup/starter_projects/Structured Data Analysis Agent.json9-32
Sources:
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.