files
Classes
FilesClient
FilesClient(client: OWUIClientBase)
Bases: ResourceBase
Client for managing files, including upload, download, and metadata operations.
- Code Reference client Classes OpenWebUI Attributes files
Source code in src/owui_client/client_base.py
Functions
upload_file
upload_file(
file: Union[bytes, tuple],
metadata: Optional[dict | str] = None,
process: bool = True,
process_in_background: bool = True,
) -> FileModelResponse
Upload a file to the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Union[bytes, tuple]
|
The file to upload. Can be: - bytes: Raw file content. Filename will be auto-generated or missing. - tuple: (filename, file_content, [content_type]). e.g., ('report.pdf', b'...', 'application/pdf'). |
required |
metadata
|
Optional[dict | str]
|
Optional metadata dict or JSON string to attach to the file. |
None
|
process
|
bool
|
If True, the system will attempt to extract text/content from the file immediately. |
True
|
process_in_background
|
bool
|
If True, processing happens asynchronously. If False, waits for processing (slower). |
True
|
Returns:
| Type | Description |
|---|---|
FileModelResponse
|
|
Source code in src/owui_client/routers/files.py
list_files
list_files(content: bool = True) -> list[FileModelResponse]
List all files accessible to the current user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
bool
|
If True, includes the 'content' field in the response (if available). If False, the content field is stripped to reduce payload size. |
True
|
Returns:
| Type | Description |
|---|---|
list[FileModelResponse]
|
list[FileModelResponse]: A list of file objects. |
Source code in src/owui_client/routers/files.py
search_files
search_files(
filename: str, content: bool = True
) -> list[FileModelResponse]
Search for files by filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Filename pattern to search for. Supports wildcards such as '*.txt'. |
required |
content
|
bool
|
If True, includes the 'content' field in the response. |
True
|
Returns:
| Type | Description |
|---|---|
list[FileModelResponse]
|
list[FileModelResponse]: A list of matching files. |
Source code in src/owui_client/routers/files.py
delete_all_files
Delete ALL files in the system.
Requires Admin privileges.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Success message. |
get_file_by_id
get_file_by_id(id: str) -> Optional[FileModel]
Get detailed information about a specific file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
Returns:
| Type | Description |
|---|---|
Optional[FileModel]
|
Optional[FileModel]: The file details if found, None otherwise. |
Source code in src/owui_client/routers/files.py
delete_file_by_id
Delete a specific file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file to delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Success message. |
Source code in src/owui_client/routers/files.py
get_file_process_status
Get the processing status of a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
stream
|
bool
|
If True, returns an SSE stream (not fully supported). Use False for a one-time status check. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The status object (e.g. {"status": "completed"}). |
Source code in src/owui_client/routers/files.py
get_file_data_content_by_id
Get the extracted text content of a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Wrapper containing the content, e.g. {"content": "Extracted text..."}. |
Source code in src/owui_client/routers/files.py
update_file_data_content_by_id
Update the extracted text content of a file manually.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
content
|
str
|
The new text content. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated content wrapper. |
Source code in src/owui_client/routers/files.py
get_file_content_by_id
Download the raw file content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
attachment
|
bool
|
If True, sets Content-Disposition to attachment. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The raw file content. |
Source code in src/owui_client/routers/files.py
get_html_file_content_by_id
Get the file content to be served as HTML.
Restricted to files owned by an Admin user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The UUID of the file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The file content. |