All Products
Search
Document Center

Platform For AI:File type input and output

Last Updated:Nov 05, 2025

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.

image

  • 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.

    image

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.

Note

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

source_uri

str

Required. The original location of the file. The following formats are supported:

  • HTTP/HTTPS URL: https://example.com/doc.pdf

  • OSS URI: oss://my-bucket/path/file.txt

  • The local path of a file in the container mount path.

"https://files.example.com/report.pdf"

download_url

str, optional

A downloadable HTTP/HTTPS link.

  • If this parameter is not provided, the system automatically generates a link.

  • If the source is an OSS URI, a signed URL that is valid for seven days is generated. If the link expires, you can call File.get_download_url() to refresh and obtain the latest signed URL.

"https://oss-cn-beijing.aliyuncs.com/my-bucket/...?Expires=...&OSSAccessKeyId=..."

file_id

str, optional

The unique identifier of the file. If this parameter is not provided, the system generates an 8-digit universally unique identifier (UUID).

"a1b2c3d4"

file_name

str, optional

The file name. If this parameter is not provided, the system automatically infers it from source_uri.

"annual_summary_report.docx"

file_type

str, optional

The Multipurpose Internet Mail Extensions (MIME) type of the file, such as application/pdf. If this parameter is not provided, the system automatically infers it based on the file name extension.

"application/vnd.openxmlformats-officedocument.wordprocessingml.document"

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

content

str

Required. The string content to be saved. The content is encoded in UTF-8 before it is uploaded.

"# Generate Report\nThis content is automatically generated by the system."

file_name

str

Required. The name of the generated file.

"report.md"

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

content

bytes

Required. The binary data to be saved.

b"%PDF-1.4\n1 0 obj\n<< /Type /Catalog >>\nendobj\n"

file_name

str

Required. The name of the generated file.

"test.pdf"

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

local_path

str

Required. The path in the local file system.

"/tmp/report.docx"

file_name

str, optional

The name of the generated file. If this parameter is not provided, the file name in local_path is used.

"final_report.docx"

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

stream

str | bytes | BinaryIO | Iterator[bytes]

Required. The data source. It can be:

  • An HTTP/HTTPS URL string

  • A bytes object

  • An io.BytesIO stream

  • A requests.Response object (with stream=True)

  • Any iterable byte object

"https://example.com/large-video.mp4"

file_name

str

Required. The name of the generated file.

"downloaded_video.mp4"

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.

image

image

image

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 AliyunOSSFullAccess permission to the custom role. Otherwise, LangStudio cannot perform file input and output operations.

To view the default workspace path, see the following figure:

image

Create a runtime:

image

Deploy an application flow:

image