In LangStudio, you can use file-type variables to accept and output files, and process them using document parsing nodes or Python nodes.
1. Start node input
In the Start node, you can define a File-type input variable to accept files uploaded by users as the initial input for the workflow.

The following file types are supported:
Document types: PDF, DOCX, PPTX, XLSX, XLS, TXT, MD, CSV, JSONL, HTML, and HTM
Image types: JPG, JPEG, PNG, BMP, and TIFF
Audio types: MP3, WAV, and AAC
Video types: MP4, MOV, AVI, MKV, M4V, WMV, FLV, ASF, and QT
After you define a file-type variable in the start node, click Parameter Configuration in the conversation panel. You can upload files using one of two methods: Upload From Local or Enter URL. When you use the Enter URL method, the supported file types include the following:
OSS URI: A file storage path that complies with Alibaba Cloud OSS specifications, such as
oss://bucket-name/path/to/file.pdf.HTTP/HTTPS link: A downloadable link that can be accessed over the Internet, such as
https://example.com/file.docx.

2. File processing
File-type inputs can be processed using document parsing nodes or Python nodes.
2.1. Document parsing node
For more information, see Document Parsing.
2.2. Custom usage in Python nodes
In a Python node, you can reference a file-type variable as a node input or generate a file-type object as a node output.
File is the core type that LangStudio uses to represent files. You must import the dependency package using from langstudio.types import File.
LangStudio provides multiple methods to construct File type objects and upload them to your OSS storage path.
Direct construction
Directly create a File object. This is the most basic construction method and is suitable for referencing existing files.
Parameter | Type | Description | Example value |
|
| Required. The original location of the file. The following formats are supported:
|
|
|
| A downloadable HTTP/HTTPS link.
|
|
|
| The unique identifier of the file. If this parameter is not provided, the system generates an 8-digit universally unique identifier (UUID). |
|
|
| The file name. If this parameter is not provided, the system automatically infers it from |
|
|
| The Multipurpose Internet Mail Extensions (MIME) type of the file, such as |
|
Sample code:
from langstudio.types import File
file = File(source_uri="https://example.com/report.pdf")
file = File(source_uri="oss://my-bucket/docs/file.docx")Construction from a string
The File.from_content() method lets you create a File type object from string content. This method is suitable for generating text files, such as Markdown, TXT, and CSV files.
Parameter | Type | Description | Example value |
|
| Required. The string content to be saved. The content is encoded in UTF-8 before it is uploaded. |
|
|
| Required. The name of the generated file. |
|
Sample code:
from langstudio.types import File
content = "# Generate Report\nThis content is automatically generated by the system."
file = File.from_content(content=content, file_name="report.md")Construction from a byte sequence
The File.from_bytes(content, file_name) method lets you create a File type object from a byte sequence. This method is suitable for processing binary files, such as PDF files, images, and Office documents.
Parameter | Type | Description | Example value |
|
| Required. The binary data to be saved. |
|
|
| Required. The name of the generated file. |
|
Sample code:
from langstudio.types import File
# Assume that pdf_data is a bytes object
file = File.from_bytes(content=pdf_data, file_name="test.pdf")Construction from a local file
The File.from_local_file(local_path, file_name) method lets you upload a local file from a mount path and create a File type object. This method is suitable for local files within a container.
Parameter | Type | Description | Example value |
|
| Required. The path in the local file system. |
|
|
| The name of the generated file. If this parameter is not provided, the file name in |
|
Sample code:
from langstudio.types import File
# Assume that the file already exists in the /tmp/ folder
file = File.from_local_file(local_path="/tmp/output.pptx", file_name="presentation.pptx")Construction from a data stream
The File.from_stream(stream, file_name) method lets you upload content from a data stream, such as a network stream, BytesIO, or an iterable object, and create a File object. This method is suitable for large files or stream processing.
Parameter | Type | Description | Example value |
|
| Required. The data source. It can be:
|
|
|
| Required. The name of the generated file. |
|
Sample code:
import io
from langstudio.types import File
url = "https://example.com/data.jsonl"
file = File.from_stream(stream=url, file_name="data.jsonl")3. End node output
In the End node, you can use a File type object as the workflow output. To view the output, click "View other outputs" in the conversation panel to view and download the workflow's output file.



4. Permission notes
Operations that involve the File type require read and write access to an OSS bucket. When you create a runtime and deploy an application flow, take note of the following:
Select the default workspace path as the current working path.
For the Instance RAM Role, we recommend that you select PAI Default Role. If you select Custom Role, you must grant the
AliyunOSSFullAccesspermission to the custom role. Otherwise, LangStudio cannot perform file input and output operations.
To view the default workspace path, see the following figure:

Create a runtime:

Deploy an application flow:
