Skip to main content
Version: 1.14.x (Next)

Manage files

Each Langflow server has a file management system where you can store files that you want to use in your flows.

Files uploaded to Langflow file management are stored in Langflow's storage backend (local or AWS S3), and they are available to all of your flows.

Uploading files to Langflow file management keeps your files in a central location, and allows you to reuse files across flows without repeated manual uploads.

Use the file management UI​

You can use the file management UI to upload files from your local machine to your own Langflow server. You can also manage all files that have been uploaded to your Langflow server.

  1. Navigate to Langflow file management:

    • Langflow Desktop: In Langflow, on the Projects page page, click My Files below the list of projects.
    • Langflow OSS: From a browser, navigate to your Langflow server's /files endpoint, such as http://localhost:7860/files. Modify the base URL as needed for your Langflow server.
    • Backend-only: For programmatic file management, use the Langflow API files endpoints. However, the following steps assume you're using the file management UI.
  2. On the My Files page, click Upload.

  3. Select one or more files to upload.

After uploading files, you can rename, download, copy, or delete files within the file management UI. To delete a file, hover over a file's icon, select it, and then click Delete. You can delete multiple files in a single action. To download a file, hover over a file's icon, select it, and then click Download. If you download multiple files in a single action, they are saved together in a zip file.

Upload and manage files with the Langflow API​

With the Langflow API, you can upload and manage files in Langflow file management, and you can send files to flows programmatically at runtime.

For more information and examples, see Files endpoints and Create a chatbot that can ingest files.

Set the maximum file size​

By default, the maximum file size is 1024 MB. To modify this value, change the LANGFLOW_MAX_FILE_SIZE_UPLOAD environment variable.

Use files in a flow​

To use files in your Langflow file management system in a flow, add a component that accepts file input to your flow, such as the Read File component.

For example, add a Read File component to your flow, click Select files, and then select files from the My Files list.

This list includes all files in your server's file management system, but you can only select file types that are supported by the Read File component. If you need another file type, you must use a different component that supports that file type, or you need to convert it to a supported type before uploading it.

For more information about the Read File component and other data loading components, see the Read file component.

Load files at runtime​

You can use preloaded files in your flows, and you can load files at runtime, if your flow accepts file input. To enable file input in your flow, do the following:

  1. Add a Read File component to your flow.

  2. Select the Read File component, click Parameters, and then click API on the Files (path) field to expose it as a tweak.

  3. Open Share > API access. The payload in each code snippet now includes tweaks with your Read File component's ID and the path key:

    "tweaks": {
    "File-qYD5w": {
    "path": []
    }
    }
  4. When you run this flow programmatically, your script must upload a file to Langflow file management, and then pass the returned file_path to the path tweak in the /run request:

    "tweaks": {
    "FILE_COMPONENT_ID": {
    "path": [ "file_path" ]
    }
    }

    For a complete example see Create a chatbot that can ingest files and Files endpoints.

    If you want to upload multiple files, you can pass multiple file_path values in the path array, such as [ "path1", "path2" ].

Upload images​

Langflow supports base64 images in the following formats:

  • PNG
  • JPG/JPEG
  • GIF
  • BMP
  • WebP

You can upload images to the Playground chat interface and as runtime input with the Langflow API.

  • In the Playground, you can drag-and-drop images into the chat input area, or you can click the Attach image icon to select an image to upload.

  • When you trigger a flow with the /api/v1/run/$FLOW_ID endpoint, you can use the files parameter to attach image data as a base64-encoded string:

    curl -X POST "http://$LANGFLOW_SERVER_ADDRESS/api/v1/run/$FLOW_ID" \
    -H "Content-Type: application/json" \
    -H "x-api-key: $LANGFLOW_API_KEY" \
    -d '{
    "session_id": "custom_session_123",
    "input_value": "What is in this image?",
    "input_type": "chat",
    "output_type": "chat",
    "files": ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."]
    }'

For more specialized image processing, browse [Bundles] or create your own components.

Work with video files​

For videos, see the Twelve Labs and YouTube Bundles.

Configure file storage​

Langflow supports two storage backends for file management.

  • Local storage: Langflow's default storage backend. Files are stored locally in your Langflow configuration directory. Set LANGFLOW_STORAGE_TYPE=local or leave it unset to use local storage.

  • S3 storage: Files are stored in an AWS S3 bucket. Langflow uses the boto3 library to interact with S3.

To use S3 as your file storage backend, add the following configuration to your .env file:

# S3 Storage Configuration
LANGFLOW_STORAGE_TYPE=s3
LANGFLOW_OBJECT_STORAGE_BUCKET_NAME=S3_BUCKET_NAME
LANGFLOW_OBJECT_STORAGE_PREFIX=S3_BUCKET_DIRECTORY

# AWS Credentials (required for S3)
AWS_ACCESS_KEY_ID=S3_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=S3_ACCESS_SECRET_KEY
AWS_DEFAULT_REGION=S3_REGION

Replace the following placeholders with the actual values for your S3 instance:

  • S3_BUCKET_NAME: The name of your S3 bucket.
  • S3_BUCKET_DIRECTORY: An optional folder path within the bucket where files are stored, such as s3://S3_BUCKET_NAME/S3_BUCKET_DIRECTORY.
  • S3_ACCESS_KEY: Your AWS Access Key ID.
  • S3_ACCESS_SECRET_KEY: Your AWS Secret Access Key.
  • S3_REGION: The AWS region where your bucket is located, such as us-east-2.

Your AWS credentials must have the necessary permissions to perform the required S3 operations for your use case, such as reading, writing, and deleting files in S3. This example policy allows basic CRUD operations on S3 objects.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LangflowS3StorageAccess",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:ListBucket",
"s3:PutObjectTagging",
],
"Resource": [
"arn:aws:s3:::S3_BUCKET_NAME",
"arn:aws:s3:::S3_BUCKET_NAME/S3_BUCKET_DIRECTORY/*"
]
}
]
}

Copy existing files to S3​

Changing LANGFLOW_STORAGE_TYPE to s3 doesn't bring the files you already have. Langflow reads and writes new files in the bucket, the previously uploaded bytes stay on local disk, and nothing reports an error until someone opens a flow that reads one.

To copy them, stop Langflow and run the following command. Set LANGFLOW_STORAGE_TYPE=local for this command, the value the instance had before the switch, so that it reads the files on local disk. The command needs the same AWS credentials Langflow uses. Before it copies anything, it checks that the bucket exists and that the credentials can reach it. If they can't, it stops there, including with --dry-run.

LANGFLOW_STORAGE_TYPE=local langflow relocate-files --bucket S3_BUCKET_NAME --prefix S3_BUCKET_DIRECTORY

Each file keeps its key. Chat history records each attachment by its absolute path on local disk, which the S3 backend can't read, so the command rewrites those paths to the <id>/<file name> form both backends read. A path it can't match to a stored file is reported and left as it was. Nothing is deleted from local disk, files already in the bucket are skipped, and a file counts as copied only when the bucket reports an object of the same size, so you can run the command again after an interrupted run. A file already in the bucket with the same size but different content, such as a file edited between runs, is reported rather than skipped. The content comparison uses the object's MD5, which S3 provides for files uploaded in one part without SSE-KMS or customer-provided keys. For other objects, including files larger than 8 MiB, which the command uploads in parts, it compares size only and says so. Files stream from disk to the bucket, so a large file isn't loaded into memory. The command copies 4 files at a time. Set --concurrency to change that; each file in flight holds at most 8 MiB. Add --dry-run to see what it would copy, and --username to limit it to one user's files.

Add --json to run the command from another program. Standard output then carries one JSON object per line, and logs go to standard error:

  • progress: the files done, the total, and the bytes copied so far. The first one is sent at the start with "phase": "checking" and a total of null, because the files aren't counted yet. The next ones have "phase": "copying" and the real total: one as soon as the files are counted, then one as each file finishes.
  • item: one result, sent as each file finishes. Chat history rewrites and uploaded files with no bytes on local disk follow the copies.
  • error: the command refused to start, or a signal stopped it. A refusal has the code schema_mismatch, source_not_local, no_such_user, or bucket_error. A run stopped by SIGINT or SIGTERM ends with an error whose code is interrupted, and exits with 130 for SIGINT or 143 for SIGTERM.
  • report: the last line of a run that reached its end, with the counts for each status, the bytes copied, and the failed items under attention.

Each failed item has a code next to its reason:

CodeMeaning
file_​conflictThe bucket already holds a different object under the file's key.
bad_​nameThe file or its folder has a name that object storage rejects, such as one containing ...
no_​source_​bytesThe file has no bytes on local disk.
attachment_​unmatchedA chat attachment path matches no stored file.
bucket_​errorS3 refused or couldn't be reached, for example because of credentials, permissions, or the network.
verify_​failedAfter the copy, the bucket didn't report an object of the same size.
copy_​failedAny other failure.

The command rewrites chat history paths in the database that LANGFLOW_DATABASE_URL points to, so set it to the database the S3-backed deployment uses. If you converted a SQLite database for that deployment, that's the converted database. Without LANGFLOW_DATABASE_URL, the command rewrites the default SQLite database instead, and the deployment's database keeps the absolute paths. Set LANGFLOW_CONFIG_DIR to the source instance's configuration directory, because local storage reads the files from there.

The command copies uploads, chat attachments and files attached to flows. Profile pictures and knowledge bases are stored outside the file storage backend, so they stay on local disk.

Replace the following placeholders with the actual values for your IAM policy and S3 instance:

  • S3_BUCKET_NAME: The name of your S3 bucket.
  • S3_BUCKET_DIRECTORY: An optional folder path within the bucket where files are stored, such as s3://S3_BUCKET_NAME/S3_BUCKET_DIRECTORY.

For more information, see the AWS documentation.

Google Drive storage is available through the Read File and Write file components, but you cannot use environment variables to configure it.

File storage environment variables​

The following environment variables configure file storage backends for Langflow's file management system:

VariableFormatDefaultDescription
LANGFLOW_​STORAGE_​TYPEStringlocalSet the file storage backend. Supported values: local (files stored in the Langflow configuration directory) or s3 (files stored in AWS S3). For S3 storage, you must also configure AWS credentials and bucket settings.
LANGFLOW_​OBJECT_​STORAGE_​BUCKET_​NAMEStringNot setThe name of the S3 bucket to use for file storage. Required when LANGFLOW_​STORAGE_​TYPE=s3.
LANGFLOW_​OBJECT_​STORAGE_​PREFIXStringNot setOptional prefix/folder path within the S3 bucket where files will be stored. If not set, files are stored at the bucket root.
LANGFLOW_​OBJECT_​STORAGE_​TAGSJSON objectNot setOptional S3 object tags applied to stored files when LANGFLOW_​STORAGE_​TYPE=s3. Ignored for local storage. Provided as a JSON map of string keys to string values, such as {"env": "prod", "owner": "data-team"}.

See also​

Was this page helpful?

Support
Search